[Qt-qml] Q_INVOKABLE member function: Valid argument types

Jonathan Zhong jonathan.zhong at panasonic.aero
Tue Oct 11 19:06:59 CEST 2011


Hi,

What are the valid argument types of an invokable member function of a 
QML extension C++ class? I have noticed that these work:

Q_INVOKABLE void myFunc1(int myInputInt);
Q_INVOKABLE void myFunc2(int & myInputInt);    // but myInputInt cannot 
be modified.

while this does not work:

Q_INVOKABLE void myFunc3(int * myOutputInt);    // This will cause a 
runtime error when running qmlviewer.

It appears that:
1. The argument can be an object of (or reference to) a basic C/C++ data 
type (int, int &, double, double &, ...).
2. The argument can be an object or (or reference to) a Qt class which 
relates to a basic QML type (QString, QString &, QVariant, QVariant &, ...).
3. The argument can be a pointer to QObject or its derived classes 
(QObject *, QWidget *, ...).
...

Is there a Qt documentation page on this subject?

Perhaps this is a related question: What are the valid return types of 
an invokable member function?


Thanks,

Jonathan






Disclaimer: The information contained in this transmission, including any 
attachments, may contain confidential information of Panasonic Avionics
Corporation.  This transmission is intended only for the use of the 
addressee(s) listed above.  Unauthorized review, dissemination or other use 
of the information contained in this transmission is strictly prohibited. 
If you have received this transmission in error or have reason to believe 
you are not authorized to receive it, please notify the sender by return 
email and promptly delete the transmission.




More information about the Qt-qml mailing list