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. Communication between C++ and QML
Forum Updated to NodeBB v4.3 + New Features

Communication between C++ and QML

Scheduled Pinned Locked Moved QML and Qt Quick
6 Posts 4 Posters 4.3k 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.
  • H Offline
    H Offline
    Hedge
    wrote on last edited by
    #1

    I want to change the image on a Button via a C++ function (trigger a state-change or however it is done).

    How can I achieve this?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on last edited by
      #2

      For example you can emit signal from cpp, cennect to it in qml via Connection and do there whatever you want. Or you can change property of your object (but to do it you need to find it in objects tree).

      1 Reply Last reply
      0
      • H Offline
        H Offline
        Hedge
        wrote on last edited by
        #3

        Ah thank you. Can I find an example on this here?

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          One way is this:

          You create a QObject derived class, that you give a property for the image URL, and make sure that property has a proper notify signal. Then, you put an instance of that class as a property in your QDeclarativeContext using setContextProperty. That makes the object accessible from within QML, where you can simply bind against the property name for the image URL.

          1 Reply Last reply
          0
          • Z Offline
            Z Offline
            ZapB
            wrote on last edited by
            #5

            Take a look at this "thread":http://developer.qt.nokia.com/forums/viewthread/4491/#30571 and get a checkout of the code from subversion that I made. This demonstrates exactly what you need.

            Nokia Certified Qt Specialist
            Interested in hearing about Qt related work

            1 Reply Last reply
            0
            • H Offline
              H Offline
              Hedge
              wrote on last edited by
              #6

              Thanks everyone. I figured it out due to your help.

              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