[Qt-qml] Q_INVOKABLE member function: Valid argument types
Girish Ramakrishnan
girish at forwardbias.in
Tue Oct 11 20:02:58 CEST 2011
Hi Jonathan,
On Tue, Oct 11, 2011 at 10:36 PM, Jonathan Zhong
<jonathan.zhong at panasonic.aero> wrote:
> 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?
>
See http://doc.qt.nokia.com/main-snapshot/qtbinding.html#supported-data-types
Girish
More information about the Qt-qml
mailing list