el desarrollo de Go-QT5 de la barra de herramientas
observaciones
- La barra de herramientas proporciona un acceso rápido a la entrada.
- En nuestro ejemplo, hemos creado una barra de herramientas sencilla. Hay un botón de barra de herramientas, haga clic para cerrar la ventana.
- Creamos un evento QAction.
- El evento tiene una etiqueta, icono y teclas de acceso directo para salir del método de la ventana.
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()
}