How can I call a pointer of an QObject in a QML File?

前端 未结 2 1428
离开以前
离开以前 2021-01-14 04:08

I\'m developping an application for Blackberry 10 and I\'m using the Momentics IDE (BB native SDK).

I get the following error when I try to execute the code below. A

相关标签:
2条回答
  • 2021-01-14 04:54

    You need to register your pointer type like this

    qRegisterMetaType<ClassA*>("ClassA*");
    

    (source)

    0 讨论(0)
  • 2021-01-14 04:59

    DataHandler is unknown type.

    Q_PROPERTY docu says:

    The type can be any type supported by QVariant

    I'd try to encapsulate your DataHandler* in QVariant and make the property of type QVariant.

    You could create the value containing your DataHandler pointer e.g like this:

    const int DATA_HANDLER = QVariant::UserType +1;
    //...
    QVariant dataHandler( DATA_HANDLER, myDataHandlerPointer );
    
    0 讨论(0)
提交回复
热议问题