No, if you have to do something like below, you are not doing it correctly :-)
Instead expose your C++ object to QML and call the c++ slot from QML. Girish On Sat, Sep 10, 2011 at 8:07 AM, Christian Benjamin Ries <[email protected]> wrote: > Solved: > [CPP] > for(int i=0; i<COUNT; i++) { > QString objName = QString("service%1").arg(i); > QObject *serviceObject = objectHost->findChild<QObject*>(objName); > connect(serviceObject, SIGNAL(serviceIndicatorClicked(int)), > this, SLOT(serviceIndicatorClicked(int))); > } > [/CPP] > > Am 10/09/11 14:28, schrieb Christian Benjamin Ries: > > Hello, > > can you give me an advice how I could connect signals by childs to my > C++-implementation? > > I have following QML-structure: > [QML] > // Service.qml > Item { > id: service; > signal serviceIndicatorClicked(int index); > > Rectangle { > id: serviceIndicator; > ... > MouseArea { > anchors.fill: parent; > acceptedButtons: Qt.LeftButton; > onClicked: { > serviceIndicatorClicked(index); > } > } > } > } > > // Host.qml > Rectangle { > id: hostItem; > > Service { > ... > } > } > [/QML] > > I try to connect this signal with following lines: > [CPP] > connect(objectHost, SIGNAL(serviceIndicatorClicked(int)), > this, SLOT(serviceIndicatorClicked(int))); > [/CPP] > > Then my result is: > [OUTPUT] > > Object::connect: No such signal Host_QMLTYPE_1::serviceIndicatorClicked(int) > > Object::connect: (receiver name: 'MainWindow') > > [/OUTPUT] > > Of course, this makes sense to me, because the signal of the child is not > visible and not part of Host, right? > > Is there an easy way to use this signal? > > Cheers, Christian > > > _______________________________________________ > Qt-qml mailing list > [email protected] > http://lists.qt.nokia.com/mailman/listinfo/qt-qml > > -- > Dipl.-Ing. (FH) Christian Benjamin Ries, M.Sc. > University of Applied Sciences Bielefeld > Department of Engineering Sciences and Mathematics > Computational Materials Science & Engineering (CMSE) > > Wilhelm-Bertelsmann-Str. 10, D-33602 Bielefeld > Office: 202 (WBSII) > Phone: +49 521 106-71222 > Fax: +49 521 106-71241 > Web: www.christianbenjaminries.de > > _______________________________________________ > Qt-qml mailing list > [email protected] > http://lists.qt.nokia.com/mailman/listinfo/qt-qml > > _______________________________________________ Qt-qml mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt-qml
