How to “pull” data from c++ to qml?What are the differences between a pointer variable and a reference variable in C++?How do I iterate over the words of a string?How can I profile C++ code running on Linux?The Definitive C++ Book Guide and ListWhat is the effect of extern “C” in C++?What is the “-->” operator in C++?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Why is reading lines from stdin much slower in C++ than Python?How to pass data from QML to C++ as a mutable referenceQML: passing JS object to C++ member function

What rules turn any attack that hits a given target into a critical hit?

What kind of anatomy does a centaur have?

Do I care if the housing market has gone up or down, if I'm moving from one house to another?

Were the Apollo broadcasts recorded locally on the LM?

Does Impedance Matching Imply any Practical RF Transmitter Must Waste >=50% of Energy?

Why is DC so, so, so Democratic?

Wiring IKEA light fixture into old fixture

High income and difficulty during interviews

Can GPL and BSD licensed applications be used for government work?

What's the 1 inch size square knob sticking out of wall?

Book in which the "mountain" in the distance was a hole in the flat world

Would using carbon dioxide as fuel work to reduce the greenhouse effect?

I have a domain, static IP address and many devices I'd like to access outside my house. How do I route them?

Considerations when providing money to one child now, and the other later?

how to add 1 milliseconds on a datetime string?

Are rockets faster than airplanes?

How to run a substitute command on only a certain part of the line

How did pilots avoid thunderstorms and related weather before “reliable” airborne weather radar was introduced on airliners?

Company requiring me to let them review research from before I was hired

What is "It is x o'clock" in Japanese with subject

How can I show that the speed of light in vacuum is the same in all reference frames?

Why are Oscar, India, and X-Ray (O, I, and X) not used as taxiway identifiers?

How to apply dcolumn in my longtable case? Need help

On the history of Haar measure



How to “pull” data from c++ to qml?


What are the differences between a pointer variable and a reference variable in C++?How do I iterate over the words of a string?How can I profile C++ code running on Linux?The Definitive C++ Book Guide and ListWhat is the effect of extern “C” in C++?What is the “-->” operator in C++?C++11 introduced a standardized memory model. What does it mean? And how is it going to affect C++ programming?Why is reading lines from stdin much slower in C++ than Python?How to pass data from QML to C++ as a mutable referenceQML: passing JS object to C++ member function






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I want "pull"data from c++ in qml like this:



 Component.onCompleted: 
MySettings.loadMainWindowPosition(aAppWnd.x, aAppWnd.y, aAppWnd.width, aAppWnd.height, aAppWnd.visibility);



When MySettings registered in the following way:



context->setContextProperty("MySettings", m_settings);


But when I make the funtion signature like this:



void MySettings::loadMainWindowPosition(int& x, int& y, int& width, int& height, int& visibility)


I received the following error:




qrc:/GUI/App.qml:35: Error: Unknown method parameter type: int&




So how correctly "pull" data inside qml from c++?



UPDATE:



I explain better. Now I can call the c++ function (and send params) from qml:



 Component.onCompleted: 
MySettings.someFunc(111, 222);



In c++ code I receive function call with params values "111" and "222".



But I want change this parameters in c++. I want smth like that:



 Component.onCompleted: 
var a;
var b;
MySettings.someFunc(a, b);



I want set up in the c++ code params to the "333" and "555". So after call MySettings.someFunc(a, b) I expected that (a==333) and (b==555).



How to do this?










share|improve this question



















  • 1





    You cannot pass a reference, this type isn't supported in js. See here for more info. Pass an object with properties instead and so update it in QML.

    – folibis
    Mar 26 at 16:50












  • @folibis could you please provide some example? I read your link but didnt get how to call c++ function that return values in params from qml :(

    – AeroSun
    Mar 26 at 20:40

















0















I want "pull"data from c++ in qml like this:



 Component.onCompleted: 
MySettings.loadMainWindowPosition(aAppWnd.x, aAppWnd.y, aAppWnd.width, aAppWnd.height, aAppWnd.visibility);



When MySettings registered in the following way:



context->setContextProperty("MySettings", m_settings);


But when I make the funtion signature like this:



void MySettings::loadMainWindowPosition(int& x, int& y, int& width, int& height, int& visibility)


I received the following error:




qrc:/GUI/App.qml:35: Error: Unknown method parameter type: int&




So how correctly "pull" data inside qml from c++?



UPDATE:



I explain better. Now I can call the c++ function (and send params) from qml:



 Component.onCompleted: 
MySettings.someFunc(111, 222);



In c++ code I receive function call with params values "111" and "222".



But I want change this parameters in c++. I want smth like that:



 Component.onCompleted: 
var a;
var b;
MySettings.someFunc(a, b);



I want set up in the c++ code params to the "333" and "555". So after call MySettings.someFunc(a, b) I expected that (a==333) and (b==555).



How to do this?










share|improve this question



















  • 1





    You cannot pass a reference, this type isn't supported in js. See here for more info. Pass an object with properties instead and so update it in QML.

    – folibis
    Mar 26 at 16:50












  • @folibis could you please provide some example? I read your link but didnt get how to call c++ function that return values in params from qml :(

    – AeroSun
    Mar 26 at 20:40













0












0








0








I want "pull"data from c++ in qml like this:



 Component.onCompleted: 
MySettings.loadMainWindowPosition(aAppWnd.x, aAppWnd.y, aAppWnd.width, aAppWnd.height, aAppWnd.visibility);



When MySettings registered in the following way:



context->setContextProperty("MySettings", m_settings);


But when I make the funtion signature like this:



void MySettings::loadMainWindowPosition(int& x, int& y, int& width, int& height, int& visibility)


I received the following error:




qrc:/GUI/App.qml:35: Error: Unknown method parameter type: int&




So how correctly "pull" data inside qml from c++?



UPDATE:



I explain better. Now I can call the c++ function (and send params) from qml:



 Component.onCompleted: 
MySettings.someFunc(111, 222);



In c++ code I receive function call with params values "111" and "222".



But I want change this parameters in c++. I want smth like that:



 Component.onCompleted: 
var a;
var b;
MySettings.someFunc(a, b);



I want set up in the c++ code params to the "333" and "555". So after call MySettings.someFunc(a, b) I expected that (a==333) and (b==555).



How to do this?










share|improve this question
















I want "pull"data from c++ in qml like this:



 Component.onCompleted: 
MySettings.loadMainWindowPosition(aAppWnd.x, aAppWnd.y, aAppWnd.width, aAppWnd.height, aAppWnd.visibility);



When MySettings registered in the following way:



context->setContextProperty("MySettings", m_settings);


But when I make the funtion signature like this:



void MySettings::loadMainWindowPosition(int& x, int& y, int& width, int& height, int& visibility)


I received the following error:




qrc:/GUI/App.qml:35: Error: Unknown method parameter type: int&




So how correctly "pull" data inside qml from c++?



UPDATE:



I explain better. Now I can call the c++ function (and send params) from qml:



 Component.onCompleted: 
MySettings.someFunc(111, 222);



In c++ code I receive function call with params values "111" and "222".



But I want change this parameters in c++. I want smth like that:



 Component.onCompleted: 
var a;
var b;
MySettings.someFunc(a, b);



I want set up in the c++ code params to the "333" and "555". So after call MySettings.someFunc(a, b) I expected that (a==333) and (b==555).



How to do this?







c++ qt qml qt5 qqmlcomponent






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 26 at 20:48







AeroSun

















asked Mar 26 at 14:29









AeroSunAeroSun

5641 gold badge6 silver badges30 bronze badges




5641 gold badge6 silver badges30 bronze badges







  • 1





    You cannot pass a reference, this type isn't supported in js. See here for more info. Pass an object with properties instead and so update it in QML.

    – folibis
    Mar 26 at 16:50












  • @folibis could you please provide some example? I read your link but didnt get how to call c++ function that return values in params from qml :(

    – AeroSun
    Mar 26 at 20:40












  • 1





    You cannot pass a reference, this type isn't supported in js. See here for more info. Pass an object with properties instead and so update it in QML.

    – folibis
    Mar 26 at 16:50












  • @folibis could you please provide some example? I read your link but didnt get how to call c++ function that return values in params from qml :(

    – AeroSun
    Mar 26 at 20:40







1




1





You cannot pass a reference, this type isn't supported in js. See here for more info. Pass an object with properties instead and so update it in QML.

– folibis
Mar 26 at 16:50






You cannot pass a reference, this type isn't supported in js. See here for more info. Pass an object with properties instead and so update it in QML.

– folibis
Mar 26 at 16:50














@folibis could you please provide some example? I read your link but didnt get how to call c++ function that return values in params from qml :(

– AeroSun
Mar 26 at 20:40





@folibis could you please provide some example? I read your link but didnt get how to call c++ function that return values in params from qml :(

– AeroSun
Mar 26 at 20:40












2 Answers
2






active

oldest

votes


















1














Don't try to get the return values as reference parameters when calling C++ functions from QML. Instead, use return values. To transfer more than one value in a single call, define your C++ method like



Q_INVOKABLE QVariantList someFunc() ... 


and use it in QML via



Component.onCompleted: 
var returnValues = MySettings.someFunc();
//access the returnValues via list indices here:
var a = returnValues[0];
var b = returnValues[1];






share|improve this answer






























    1














    Passing values ​​by reference do not work calling c ++ functions from QML. If you want sync calls, use something link this in your c ++ code:



    QVariantList MySettings::someFunc(int a, int b)

    QVariantList list;
    list.append(a + 5); // edit the passed values here
    list.append(b + 5); // edit the passed values here
    return list;



    and something like this in your QML code:



    var test = gapi.someFunc(3,2); // pass values here and get the new ones
    console.log("The return data" + test);





    share|improve this answer

























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55359615%2fhow-to-pull-data-from-c-to-qml%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      Don't try to get the return values as reference parameters when calling C++ functions from QML. Instead, use return values. To transfer more than one value in a single call, define your C++ method like



      Q_INVOKABLE QVariantList someFunc() ... 


      and use it in QML via



      Component.onCompleted: 
      var returnValues = MySettings.someFunc();
      //access the returnValues via list indices here:
      var a = returnValues[0];
      var b = returnValues[1];






      share|improve this answer



























        1














        Don't try to get the return values as reference parameters when calling C++ functions from QML. Instead, use return values. To transfer more than one value in a single call, define your C++ method like



        Q_INVOKABLE QVariantList someFunc() ... 


        and use it in QML via



        Component.onCompleted: 
        var returnValues = MySettings.someFunc();
        //access the returnValues via list indices here:
        var a = returnValues[0];
        var b = returnValues[1];






        share|improve this answer

























          1












          1








          1







          Don't try to get the return values as reference parameters when calling C++ functions from QML. Instead, use return values. To transfer more than one value in a single call, define your C++ method like



          Q_INVOKABLE QVariantList someFunc() ... 


          and use it in QML via



          Component.onCompleted: 
          var returnValues = MySettings.someFunc();
          //access the returnValues via list indices here:
          var a = returnValues[0];
          var b = returnValues[1];






          share|improve this answer













          Don't try to get the return values as reference parameters when calling C++ functions from QML. Instead, use return values. To transfer more than one value in a single call, define your C++ method like



          Q_INVOKABLE QVariantList someFunc() ... 


          and use it in QML via



          Component.onCompleted: 
          var returnValues = MySettings.someFunc();
          //access the returnValues via list indices here:
          var a = returnValues[0];
          var b = returnValues[1];







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 26 at 21:21









          MitjaMitja

          1,75922 silver badges26 bronze badges




          1,75922 silver badges26 bronze badges























              1














              Passing values ​​by reference do not work calling c ++ functions from QML. If you want sync calls, use something link this in your c ++ code:



              QVariantList MySettings::someFunc(int a, int b)

              QVariantList list;
              list.append(a + 5); // edit the passed values here
              list.append(b + 5); // edit the passed values here
              return list;



              and something like this in your QML code:



              var test = gapi.someFunc(3,2); // pass values here and get the new ones
              console.log("The return data" + test);





              share|improve this answer



























                1














                Passing values ​​by reference do not work calling c ++ functions from QML. If you want sync calls, use something link this in your c ++ code:



                QVariantList MySettings::someFunc(int a, int b)

                QVariantList list;
                list.append(a + 5); // edit the passed values here
                list.append(b + 5); // edit the passed values here
                return list;



                and something like this in your QML code:



                var test = gapi.someFunc(3,2); // pass values here and get the new ones
                console.log("The return data" + test);





                share|improve this answer

























                  1












                  1








                  1







                  Passing values ​​by reference do not work calling c ++ functions from QML. If you want sync calls, use something link this in your c ++ code:



                  QVariantList MySettings::someFunc(int a, int b)

                  QVariantList list;
                  list.append(a + 5); // edit the passed values here
                  list.append(b + 5); // edit the passed values here
                  return list;



                  and something like this in your QML code:



                  var test = gapi.someFunc(3,2); // pass values here and get the new ones
                  console.log("The return data" + test);





                  share|improve this answer













                  Passing values ​​by reference do not work calling c ++ functions from QML. If you want sync calls, use something link this in your c ++ code:



                  QVariantList MySettings::someFunc(int a, int b)

                  QVariantList list;
                  list.append(a + 5); // edit the passed values here
                  list.append(b + 5); // edit the passed values here
                  return list;



                  and something like this in your QML code:



                  var test = gapi.someFunc(3,2); // pass values here and get the new ones
                  console.log("The return data" + test);






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 28 at 17:50









                  Adriano CamposAdriano Campos

                  1911 silver badge6 bronze badges




                  1911 silver badge6 bronze badges



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55359615%2fhow-to-pull-data-from-c-to-qml%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                      SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                      은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현