PDA

View Full Version : Connecting QML signals with Qt slots



KIBSOFT
13th November 2010, 22:24
Here is an example of qml:


Item {
signal titleBarClicked()

MouseArea {
anchor.fill: parent
onClicked: titleBarClicked()
}
}

and C++:


QDeclarativeEngine *engine = new QDeclarativeEngine;
QDeclarativeComponent component(engine, QUrl::fromLocalFile("qml/TestQML/TestQML.qml"));
QObject *myObject = component.create();
QDeclarativeItem *item = qobject_cast<QDeclarativeItem *>(myObject);
qDebug()<<QObject::connect(item, SIGNAL(titleBarClicked()), &viewer, SLOT(showMaximized()));

connect() return true, but slot is not called. What's wrong?

P.S. If you want to vote for this bug - go there (http://bugreports.qt.nokia.com/browse/QTBUG-15287)

high_flyer
15th November 2010, 10:18
Did you read the comment to the bug?