[Qt-qml] Connecting to a property's C++ signals in QML
ext-salonen.olli at nokia.com
ext-salonen.olli at nokia.com
Mon Nov 1 18:29:40 CET 2010
Hi,
Is there a way to connect to the signals of a QObject in QML if it has been set as a context property? I would like to do the following:
MyObject.h
----------------
Class MyObject {
Q_OBJECT
signal:
void connectMe();
};
main.cpp
----------------
...
QDeclarativeView view;
QDeclarativeContext* context = view.rootContext;
context->setContextProperty("myObject", new MyObject);
main.qml
-----------------
myObject.onConnectMe(): log.debug("triggered")
Is there a legal way to do that last line in QML?
If I just map the C++ object to QML through qmlRegisterType<MyObject>() and then write the QML as follows:
MyObject {
onConnectMe: log.debug("triggered")
}
then I cannot control the construction of the object. It cannot even be constructed if the object has a mandatory constructor parameter.
Thanks in advance,
Olli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt.nokia.com/pipermail/qt-qml/attachments/20101101/15c92bdd/attachment.html
More information about the Qt-qml
mailing list