c++ - In qt, how do I implement a widget that stays consistent with variables in the code -
Here is a sample of a spinbox that writes changes in the underlying variable. The main problem is that when I have a price change, when the widget is created, it is said. Is there any more elegant way to do this? I think it's weird that I have attached a widget to myself, but the value is not changed.
I'm not looking particularly odd about adding a widget to myself Am The same method of detecting and responding to data updates really sounds like a good thing because you have fewer points of failure to check if there is debugging in your specific case, it is creating some unwanted behavior, but Normally this is a good solution.
Now, expressing the opinion that a reflexive connection is not inherently inefficient, I would like to suggest that after the construction changing the value to stop calling "elegant" Less than the solution to determine if the object was created and you can have a flag to stop the code from running immediately after the creation. In your example:
class ValueWriterInt: public QSpinBox {Q_OBJECT public: ValueWriterInt (vector & lt; int *> const & value): myValue (value), myAfterInit (true) {QObject :: connect (this, signal (value change), this slot (value change);) } ~ ValueWriterInt () {} Private Slot: Null Value Changed (Intimate Newman) {if (myAfterInit) {myAfterInit = false; Return; } (Auto = myValue.begin), this! = MyValue.end (); ++ this) ** This = new_value; } Private: Vector & lt; Int * & gt; MyValue; Boolean matchfront; }; This is not very bad for a solution
Comments
Post a Comment