examples: add helloworld example

This commit is contained in:
mappu 2024-08-25 15:54:45 +12:00
parent bfbe24e275
commit 754b76d18a
3 changed files with 31 additions and 2 deletions

3
.gitignore vendored
View File

@ -7,5 +7,4 @@ cmd/handbindings/handbindings
cmd/handbindings/bindings_test/direct cmd/handbindings/bindings_test/direct
cmd/handbindings/bindings_test/testapp cmd/handbindings/bindings_test/testapp
cmd/genbindings/genbindings cmd/genbindings/genbindings
examples/helloworld/helloworld

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

View File

@ -0,0 +1,30 @@
package main
import (
"fmt"
"os"
"miqt/qt"
)
func main() {
app := qt.NewQApplication(os.Args)
_ = app
btn := qt.NewQPushButton2("Hello world!")
btn.SetFixedWidth(320)
var counter int = 0
btn.OnPressed(func() {
counter++
btn.SetText(fmt.Sprintf("You have clicked the button %d time(s)", counter))
})
btn.Show()
qt.QApplication_Exec()
fmt.Println("OK!")
}