備考
- ツールバーには、入り口への迅速なアクセスを提供します。
- この例では、シンプルなツールバーを作成しました。ツールバーのボタンがあり、クリックしてウィンドウを閉じます。
- 我々はQActionイベントを作成します。
- イベントは、ウィンドウ法を終了するには、ラベル、アイコンやショートカットキーを持っています。
demo.go
package main
import (
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/widgets"
"os"
)
func InitUi() *widgets.QMainWindow {
app := widgets.NewQMainWindow(nil, 0)
app.SetWindowTitle("Qt 教程")
app.SetGeometry2(300, 300, 300, 220)
app.SetWindowIcon(gui.NewQIcon5("images/app.ico"))
exitAction := widgets.NewQAction3(gui.NewQIcon5("images/app.ico"), "&Exit", app)
exitAction.SetShortcut(gui.NewQKeySequence2("Ctrl+Q", gui.QKeySequence__NativeText))
exitAction.ConnectTriggered(func(checked bool) {
app.Close()
})
var actions []*widgets.QAction
actions = append(actions, exitAction)
toolbar := app.AddToolBar3("Exit")
toolbar.AddActions(actions)
return app
}
func main() {
widgets.NewQApplication(len(os.Args), os.Args)
app := InitUi()
app.Show()
widgets.QApplication_Exec()
}