Is there a way to keep ui data synchronized with program data?
-
wrote on 2 May 2015, 00:37 last edited by
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?
-
wrote on 2 May 2015, 01:28 last edited by alex_malyu 5 Feb 2015, 01:29
As soon you find a way to associate any control with data it is easy,
-
wrote on 2 May 2015, 01:39 last edited by
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?
-
wrote on 2 May 2015, 05:49 last edited by DanWatkins 5 Feb 2015, 05:51
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++.
-
wrote on 2 May 2015, 15:22 last edited by
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/5