Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Dinamically change qt quick control from c++
Forum Updated to NodeBB v4.3 + New Features

Dinamically change qt quick control from c++

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 138 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 1 Offline
    1 Offline
    1XU7
    wrote on last edited by 1XU7
    #1

    Hello. i previously have made a search for this with no result, (may i selected the non apropiated key words, my apologies).

    i have a Button made in QML.. what im looking for is to change the Button's text once it is pushed....

    The Button block will call a function from my c++ code, from there, i want to change the text of the Button quick control.. is this possible or QML just will serve me as a read-only view controls?

    Example:
    main.qml:

    Button{
       id : pbtGreetings
       text : "Click here"
       onClicked : MySite.onClickButton()
    }
    

    MySite.cpp

    void MySite::onClickButton(){
        //something like:
        getQML("main.qml").pbtGreetings.text = "Pushed!";
    }
    

    thanks!

    DanimaD 1 Reply Last reply
    0
    • 1 1XU7

      Hello. i previously have made a search for this with no result, (may i selected the non apropiated key words, my apologies).

      i have a Button made in QML.. what im looking for is to change the Button's text once it is pushed....

      The Button block will call a function from my c++ code, from there, i want to change the text of the Button quick control.. is this possible or QML just will serve me as a read-only view controls?

      Example:
      main.qml:

      Button{
         id : pbtGreetings
         text : "Click here"
         onClicked : MySite.onClickButton()
      }
      

      MySite.cpp

      void MySite::onClickButton(){
          //something like:
          getQML("main.qml").pbtGreetings.text = "Pushed!";
      }
      

      thanks!

      DanimaD Offline
      DanimaD Offline
      Danima
      wrote on last edited by Danima
      #2

      @1XU7 Hi
      main.qml:

        Button{
             id : pbtGreetings
             text : "Click here"
             onClicked : MySite.onClickButton()
          }
          
          Connections
          {
              target:MySite
              
              function onNewText(s)
              {
                  pbtGreetings.text=s;
              }
          }
      

      MySite.h:

      class MySite:public QObject
      {
      Q_OBJECT
      public:
          Q_INVOKABLE void onClickButton();
      signals:
         void newText(QString s);
      
      };
      

      MySite.cpp:
      void MySite::onClickButton(){
      //something like:
      emit newText( "Pushed!");
      }

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved