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. Working with Q_PROPERTY and exposing the back end to the front end.
Forum Updated to NodeBB v4.3 + New Features

Working with Q_PROPERTY and exposing the back end to the front end.

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 441 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.
  • R Offline
    R Offline
    RobM
    wrote on last edited by
    #1

    So when I create a variable and expose it to the front end like so:

            Q_PROPERTY(bool             connected                        READ connected                         WRITE setConnected              NOTIFY connectedChanged)
    
    

    I can call the setConnected from the front end or does it automatically get called when I call connected?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      RobM
      wrote on last edited by RobM
      #2

      I believe the answer is that it calls that for me. For instance:

      object.connected = true
      

      is going to call the setConnected (setter) of the Q_PROPERTY. Whereas, saying something like:

      if(object.connected === true)
      

      is going to call connected (getter) of the Q_PROPERTY, correct? In other words, unless I plan on changing the value of connected from QML then I do not need a WRITE.

      Thanks for the correction @LeLev

      ODБOïO 1 Reply Last reply
      0
      • R RobM

        I believe the answer is that it calls that for me. For instance:

        object.connected = true
        

        is going to call the setConnected (setter) of the Q_PROPERTY. Whereas, saying something like:

        if(object.connected === true)
        

        is going to call connected (getter) of the Q_PROPERTY, correct? In other words, unless I plan on changing the value of connected from QML then I do not need a WRITE.

        Thanks for the correction @LeLev

        ODБOïO Offline
        ODБOïO Offline
        ODБOï
        wrote on last edited by
        #3

        hi

        @RobM said in Working with Q_PROPERTY and exposing the back end to the front end.:

        In other words, unless I plan on changing the value of connected from QML then I do not need a WRITE.

        yes that is correct, if you don't have the WRITE method then it will become like a read-only property

        1 Reply Last reply
        1

        • Login

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