Connecting QML signals with Qt slots
Here is an example of qml:
Code:
Item {
signal titleBarClicked()
MouseArea {
anchor.fill: parent
onClicked: titleBarClicked()
}
}
and C++:
Code:
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
Re: Connecting QML signals with Qt slots
Did you read the comment to the bug?