From b03e070e386d401b534b30b329947635778df4f2 Mon Sep 17 00:00:00 2001 From: qydysky Date: Mon, 5 Oct 2020 18:37:11 +0800 Subject: [PATCH] =?utf8?q?=E9=81=BF=E5=85=8Dqt=20panic?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Reply/qt.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Reply/qt.go b/Reply/qt.go index f610659..94cf286 100644 --- a/Reply/qt.go +++ b/Reply/qt.go @@ -3,6 +3,7 @@ package reply import ( "os" "strconv" + "os/signal" c "github.com/qydysky/bili_danmu/CV" "github.com/therecipe/qt/core" @@ -31,7 +32,7 @@ func Qtdanmu() { Qt_FontWeight = qtd.Qt_FontWeight Qt_Background = qtd.Qt_Background - widgets.NewQApplication(len(os.Args), os.Args) + wq := widgets.NewQApplication(len(os.Args), os.Args) //主窗口 mainWindow := widgets.NewQMainWindow(nil, 0) @@ -61,7 +62,7 @@ func Qtdanmu() { centralWidget.SetLayout(vbox) mainWindow.SetCentralWidget(centralWidget) mainWindow.ShowNormalDefault() - + wq.SetActiveWindow(mainWindow) go func(){ QtDanmuChan = make(chan string, 10) QtOn = true @@ -75,7 +76,16 @@ func Qtdanmu() { } } }() - widgets.QApplication_Exec() + + //ctrl+c退出 + interrupt := make(chan os.Signal, 1) + signal.Notify(interrupt, os.Interrupt) + go func(w *widgets.QApplication){ + <-interrupt + close(interrupt) + w.CloseAllWindows() + }(wq) + wq.Exec() QtOn = false } -- 2.39.2