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. Change property value from c++
Forum Updated to NodeBB v4.3 + New Features

Change property value from c++

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 2 Posters 1.1k Views 1 Watching
  • 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.
  • W Offline
    W Offline
    w00t1234
    wrote on 3 Oct 2016, 15:49 last edited by w00t1234 10 Mar 2016, 16:03
    #1

    Hi guys i need some help.

    How to change QML property value from c++ ?

    //main.cpp
    QQmlContext *ctx = engine.rootContext();
    ctx->setContextProperty("control",&allofthem);
    ctx->setProperty("text","Qt Everywhere");
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    
    //main.qml
    property string text
    .
    .
    .
    console.log(text)
    

    Result
    alt text

    1 Reply Last reply
    0
    • P Offline
      P Offline
      p3c0
      Moderators
      wrote on 3 Oct 2016, 16:32 last edited by
      #2

      @w00t1234 You should set the property after loading the QML.

      157

      W 1 Reply Last reply 3 Oct 2016, 16:46
      0
      • P p3c0
        3 Oct 2016, 16:32

        @w00t1234 You should set the property after loading the QML.

        W Offline
        W Offline
        w00t1234
        wrote on 3 Oct 2016, 16:46 last edited by
        #3

        @p3c0 said in Change property value from c++:

        @w00t1234 You should set the property after loading the QML.

        It's not work

        1 Reply Last reply
        0
        • P Offline
          P Offline
          p3c0
          Moderators
          wrote on 3 Oct 2016, 16:49 last edited by
          #4

          When are you printing the text? Use onTextChanged signal handler and print the text there.

          157

          W 1 Reply Last reply 3 Oct 2016, 16:51
          0
          • P p3c0
            3 Oct 2016, 16:49

            When are you printing the text? Use onTextChanged signal handler and print the text there.

            W Offline
            W Offline
            w00t1234
            wrote on 3 Oct 2016, 16:51 last edited by
            #5

            @p3c0 said in Change property value from c++:

            When are you printing the text? Use onTextChanged signal handler and print the text there.

            Please example

            1 Reply Last reply
            0
            • P Offline
              P Offline
              p3c0
              Moderators
              wrote on 3 Oct 2016, 16:52 last edited by
              #6

              Can you post your QML file ?

              157

              1 Reply Last reply
              0

              1/6

              3 Oct 2016, 15:49

              • Login

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