développement Go-QT5 de barre d'outils
remarques
- La barre d'outils permet d'accéder rapidement à l'entrée.
- Dans notre exemple, nous avons créé une simple barre d'outils. Il y a un bouton de la barre d'outils, cliquez pour fermer la fenêtre.
- Nous créons un événement QAction.
- L'événement a une étiquette, l'icône et les touches de raccourci pour quitter la méthode de la fenêtre.
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()
}