Important: Please read the Qt Code of Conduct -

QML behaviour different on Windows and Android !

  • Hello,

    I'm facing to a strange problem with Qt and Android

    I have a class MyClass which is used in my QML code
    In QML code I get some instance and make assignements

    class MyClass : public QObject {

    Q_PROPERTY(a::b::c::Test* selectedTest READ selectedTest WRITE
                   setSelectedTest NOTIFY selectedTestChanged)


    class Test : public QObject {

    I used
    qmlRegisterUncreatableType<Test>("a.b.c", 1, 0, "Test",
    "object Test is not instanciable");

    to be able to use Test objects in QML and ENUMs from Test

    Well following code gives different results on Windows and Android

    I have in my c++ code a function that can returns a Test* (or other things)

    QObject * xxx::searchItem(...)
    ... if (...) return a Test* else return other things

    in QML I have
    var myVar = xxx.searchItem(...)

    and in other QML file myclass.selectedTest = myVar (using signals)

    On Windows all is working fine,
    on Android I have following error message:

    Error: Cannot assign QObject* to a::b::c::Test*

    I checked that myVar has the good type but I do not understand why it does not work on Android

    I can get similar error messages for example with
    myclass.otherproperty = myVar where otherproperty is an int for example

    I use Qt 5.10.1 and compile for windows 64 bits / android armv7

    Any Idea ?

  • I created a more simple projet and it works ;(

    Well how can I debug myclass.selectedTest = myVar in QML ?
    Error message
    Error: Cannot assign xxxx to yyyy is in Qt source code ?

  • finally I found the problem !

    above code is compiled in a lib but at deployement I let the same lib with a different name and older (however with same functionnalities)
    So there were two libs with same package, functionnalities, ...
    Well it strange that it worked at 90% but that there was a problem in the QML code
    I close the topic

Log in to reply