MyTinyTodo2/guid/gui.go

52 lines
1.1 KiB
Go

package main
import (
"local/mytinytodoclient/mytinytodo"
"log"
"os"
"github.com/therecipe/qt/core"
"github.com/therecipe/qt/gui"
"github.com/therecipe/qt/qml"
)
type Buffer struct {
core.QObject
_ func() `constructor:"init"`
_ func(string) `slot:"test"`
buffer *mytinytodo.Buffer
}
func (b *Buffer) init() {
b.ConnectTest(b.test)
}
func (b *Buffer) test(s string) {
log.Printf("gui.buffer.test: %s", s)
}
func main() {
core.QCoreApplication_SetAttribute(core.Qt__AA_EnableHighDpiScaling, true)
gui.NewQGuiApplication(len(os.Args), os.Args)
Buffer_QmlRegisterType2("Buffer", 1, 0, "Buffer")
engine := qml.NewQQmlEngine(nil)
component := qml.NewQQmlComponent5(engine, core.NewQUrl3("qrc:/qml/application.qml", 0), nil)
buffer := NewBufferFromPointer(component.Create(nil).Pointer())
if buffer.Pointer() != nil {
buffer.Test("hello world")
} else {
for _, e := range component.Errors() {
log.Println(e.Description())
}
}
var app = qml.NewQQmlApplicationEngine(nil)
app.Load(core.NewQUrl3("qrc:/qml/application.qml", 0))
gui.QGuiApplication_Exec()
}