Hi,
I loaded a QML file from QT C++ class using QDeclarativeView object. I want a signal from QML file to CPP after it is active.
My sample code is :
QDeclarativeView *view = new QDeclarativeView();
view
->setSource
(QUrl::fromLocalFile("base.qml"));
Qmlview = view;
QObject *item
= view
->rootObject
();
Qmlview->show();
QDeclarativeView *view = new QDeclarativeView();
view->setSource(QUrl::fromLocalFile("base.qml"));
Qmlview = view;
QObject *item = view->rootObject();
QObject::connect(item,SIGNAL(qmlSignal(QString)),this,SLOT(cppSlot(QString)));
Qmlview->show();
To copy to clipboard, switch view to plain text mode
and in the QML side i wrote:
Rectangle {
id : item1
width: 400
height: 400
color: "#d5b9b9"
signal qmlSignal(string msg)
Component.onCompleted:
{
item1.qmlSignal("string msg")
}
}
Rectangle {
id : item1
width: 400
height: 400
color: "#d5b9b9"
signal qmlSignal(string msg)
Component.onCompleted:
{
item1.qmlSignal("string msg")
}
}
To copy to clipboard, switch view to plain text mode
but it seems that the signal will emit before the connection handler.
Is there any event in QML which will active after "Qmlview->show();" ?
Thanks in advance...
Bookmarks