c++ - How can/should I create automatic link between ui forms and data members in Qt? -
This is a common problem, I do not know how it is handled normally and I want to good (???) The way to do it: I have several types of UI with many programs. I have some structures using data provided by UI. I need to synchronize the form and data clearly. Right now I do this manually and I type this type of function: Every time I add a UI field, I have to update the set and get the function. This work looks dumb, and it is getting spoiled over time, and I have been told that the computer is good at dealing with such repetitive dumb tasks. So do you think that it would be a good idea to somehow say that every UI started with "fil_consecutive_" should be related to the structure structure option. File? How do I get that program? I will try to give you an idea. You can set on your form if you set the object number in the designer, which will be in the generated ui.hh file. Use the QList to store all the specific variations and QMap options.
option fetches data from GetOptions () {// UI and stores it in my composition options. Fil.alpha = ui.fil_consecutive_alpha - & gt; value (); Options.fil.beta = ui.fil_consecutive_beta- & gt; Values (); Options.fil.gamma = ui.fil_consecutive_gamma- & gt; Values (); Options.fil.delta = ui.fil_consecutive_delta-> Values (); Options.fil.k_max = ui.fil_consecutive_k_max- & gt; Values (); Options.fil.radius = ui.fil_consecutive_radius-> Values (); Options.fil.omega = ui.fil_consecutive_omega-> Values (); Options.fil.side_length = ui.fil_consecutive_side_length- & gt; Values (); Options.fil.norm = ui.fil_consecutive_norm- & gt; Values (); Options.fil.consecutive_images = true; } Zero Setpopes (Constant Options and Options) {// Update ui Formats Structure ui.fil_consecutive_alpha-> gt; with sdtored loaded options in setValue (options.fil.alpha); Ui.fil_consecutive_beta-> Set val (options.fil.beta); ui.fil_consecutive_gamma-> SetValue (options.fil.gamma); ui.fil_consecutive_delta-> SetValue (options.fil.delta); ui.fil_consecutive_k_max- & gt; SetValue (options.fil.k_max); ui.fil_consecutive_radius-> setValue (options.fil.radius); ui.fil_consecutive_omega-> setValue (options.fil.omega); ui.fil_consecutive_side_length- & gt; setValue (options.fil.side_length); ui.fil_consecutive_norm- & gt; setValue (options.fil.norm); }
... // Set form name ui.fil_consecutive_alpha-> SetObjectName ("fil_consecretive_omega"); ... ... this cube object list such as coach forms = ... this.children (); QObjectList forms = QObjectList (); (Int i = 0; i & lt; list.size (); ++ i) {if list [i] .objectName (). BeginWith ("fil_consecutive_") form & lt; & Lt; List [i]; ... ... // Then your functions will become zero; (int i = 0; i & lt; forms.size (+; i) for {...} for QObjectList forms {QString opt = Forms [i] .objectName (). Mid (QString ("fil_consecurive_"). Length ()) options.fil [opt] = forms [i] .property ("value"); } ...}
Comments
Post a Comment