Qt World Summit: Register Today!

How to pass QString array from .cpp to string array in qml

  • Hi everybody,
    I'm a newbie.
    I have 2 array in .cpp and .qml like:

    QString arr1[2];
    arr[0]= "";
    arr[1]= "sdfsdf";


    property variant arr2: ["null", "null"]

    I wanna pass arr1 to arr2 like arr2= arr1;
    how can I get it ???

  • Hello and welcome,

    basically you can pass a C++ Object to Qt using the setContextProperty method. For further informations i would recommend you to check our this qt doc:

    It should answer your question and explain it better than i could =)
    If you have got more questions you are free to ask here!


Log in to reply