c++ - Access QML signal deep in the hierarchy -
i trying emit signal on completion of creating object. this:
component.oncompleted: mysignal() this in qml file deep in hierarchy. see 2 solutions accessing signal in c++.
first passing signal hierarchy until main.qml , in c++ this:
//create quick view object. qquickview *view = new qquickview(); //object access qml properties , childs. qobject *container = (qobject *) view->rootobject(); //connect signal , slots qobject::connect(container, signal(mysignal()), this, slot(onmysignal())); this have tried , reason slot not called. works other signals send , emit main.qml, not 1 emitted component.oncomplete. can verify signal emitted qml side, never received on c++ side.
the second thing tried instead of passing signal main.qml, reference qml file emitting signal want. tried doing so:
//create quick view object. qquickview *view = new qquickview(); //object access qml properties , childs. qobject *container = (qobject *) view->rootobject(); //connect signal , slots qobject::connect(container->findchild<qobject*>("mysignalqmlfile"), signal(mysignal()), this, slot(onmysignal())); where mysignalqmlfile id of main rectangle has signals defined within it.
and error:
qobject::connect: no such signal qquickrectangle_qml_54::mysignal() in ..\gc\mainwindow.cpp:62
i not sure how proceed.
for first try, think possible signal emitted before connect signal , slot never received signal.
for second try, need use objectname qml file, not "mysignalqmlfile".
i recommend read following tutorial.
http://developer.nokia.com/community/wiki/using_objectname_to_find_qml_elements_from_qt
also, qml file needs called or used before connect signals , slot. otherwise, not able find object same error.
Comments
Post a Comment