Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Is there a way to keep ui data synchronized with program data?
Forum Updated to NodeBB v4.3 + New Features

Is there a way to keep ui data synchronized with program data?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 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.
  • T Offline
    T Offline
    technovelist
    wrote on 2 May 2015, 00:37 last edited by
    #1

    I have dozens of controls in my UI, and keeping the data synchronized between the UI and the program is getting to be a very big problem. Is there a way to say "synchronize text in all controls with the data in the C++ program"? If not, is there at least a way to organize this so that it doesn't take most of my development time to keep it working correctly?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      alex_malyu
      wrote on 2 May 2015, 01:28 last edited by alex_malyu 5 Feb 2015, 01:29
      #2

      As soon you find a way to associate any control with data it is easy,

      1 Reply Last reply
      0
      • T Offline
        T Offline
        technovelist
        wrote on 2 May 2015, 01:39 last edited by
        #3

        I can do it for each control, but I have many controls and it is a real pain to keep them all synchronized. Is there a generic way to do it for all controls?

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DanWatkins
          wrote on 2 May 2015, 05:49 last edited by DanWatkins 5 Feb 2015, 05:51
          #4

          If you are using Qt Quick, you should wrap your program data each in a Q_PROPERTY and implement an intelligent notify signal indicating the data has changed. Then in your QML, just bind a control's value to a particular property exposed from C++.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            technovelist
            wrote on 2 May 2015, 15:22 last edited by
            #5

            I don't think I'm using Qt Quick. I'm pretty sure I'm not using QML.
            My program is written using VS 2013 and I have the Qt plugin that runs the moc step.
            Can I use Q_PROPERTY in this environment? Or if not, is it hard to switch to Qt Quick?

            My current plan is to write some C++ classes, e.g., qtInt, qtFloat, that will automatically synchronize data from the C++ variable to the UI, and a code generator that will create a connect statement for each variable to synchronize the other way. Then I'll just use those classes in my program instead of int, float, etc. Does that sound like it will work?

            1 Reply Last reply
            0

            1/5

            2 May 2015, 00:37

            • Login

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