examples/subclass: also test KeyPressEvent

This commit is contained in:
mappu 2024-11-23 18:33:04 +13:00
parent f45604ee13
commit c6018d1c07

View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"fmt"
"os" "os"
"github.com/mappu/miqt/qt" "github.com/mappu/miqt/qt"
@ -48,6 +49,12 @@ func main() {
w.Update() // repaints in next event loop tick w.Update() // repaints in next event loop tick
}) })
w.OnKeyPressEvent(func(super func(ev *qt.QKeyEvent), ev *qt.QKeyEvent) {
super(ev)
w.SetTitle(fmt.Sprintf("Keypress %d", ev.Key()))
})
w.Show() w.Show()
qt.QApplication_Exec() qt.QApplication_Exec()