Closed eivindro closed 10 years ago
@eivindro, the following works:
package main
import (
"fmt"
"github.com/niemeyer/qml"
)
func main() {
qml.Init(nil)
engine := qml.NewEngine()
component, err := engine.LoadFile("qmltest2.qml")
if err != nil {
panic(err)
}
window := component.CreateWindow(nil)
window.Root().On("closeButtonClicked", func() { fmt.Println("Close button was clicked") })
window.Show()
window.Wait()
}
@oblitum You are right your way works. Hmm, it is a bit difficult to map the QML C++ documention to go-qml sometimes. Anyway, thanks!
I get a runtime panic when running the below code:
panic: object does not expose a "closeButtonClicked" signal
I got it to work fine in C++ with the same qml file.
package main
import ( "fmt" "github.com/niemeyer/qml" )
func main() { qml.Init(nil) engine := qml.NewEngine() component, err := engine.LoadFile("qmltest2.qml") if err != nil { panic(err) }
}
import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Window 2.0 import QtQuick.Layouts 1.0
Item { id: root width: 200 height: 200
}