I have multiple QLineEdit
widgets on a configuration widget.
When the configuration text is changed I want to store the updated value (there are a few of them so I don't want to pass them in one function call at the end).
I was thinking to connect them to one slot or go through QSignalMapper
to one slot.
However I'm having trouble finding an elegant way to tell the QLineEdit
s apart, I want to know which QLineEdit emitted the signal - since I'm in handler object that implements the logic I can't compare the sender()
with the original object.
I can hook them up through QSignalMapper
so that my handler gets either int id
or QObject*
or QWidget*
reference to the actual widget that emitted the signal so I can get easily the new text, but I would like to be able to switch on some id to update the correct setting internally.
Is there any elegant way to tag or label Qt objects or widgets?
Dynamic properties allow you to 'tag' extra data at run-time onto any QObject derived class. See the QObject::setProperty
documentation.
I personally don't like using dynamic properties as they aren't documented in the header of the class. I prefer to inherit from the class and add a standard property.