Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

signal slot connection fail #8

Closed
eivindro opened this issue Sep 28, 2013 · 2 comments
Closed

signal slot connection fail #8

eivindro opened this issue Sep 28, 2013 · 2 comments

Comments

@eivindro
Copy link
Contributor

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)
}

window := component.CreateWindow(nil)
component.On("closeButtonClicked", func() { fmt.Println("Close button was clicked") })

window.Show()
window.Wait()

}


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

signal closeButtonClicked()

ColumnLayout {
    anchors.fill: parent
    anchors.margins: 3
    spacing: 2
    Button {
        objectName: "mCloseButton"
        id: mCloseButton;
        text: qsTr("Close")
        anchors.horizontalCenter: parent.horizontalCenter
        onClicked: root.closeButtonClicked()
    }
}

}

@oblitum
Copy link
Contributor

oblitum commented Sep 28, 2013

@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()
}

@eivindro
Copy link
Contributor Author

@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!

ricochet1k referenced this issue in limetext/qml-go Aug 19, 2016
Fix warnings regarding PyObject_HEAD_INIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants