PDA

View Full Version : How to Map member variables with Qt Widgets?



rajeshs
18th December 2007, 11:23
Hi all,

I want to map some member variables with Qt Widgets . For example i have 2 QLineEdit contrtols for hours and minutes , I want to update currosponding members whenever these 2 widgets are getting changed , Is there any mechanism in Qt to do this?

marcel
18th December 2007, 11:28
Yeah, what about signals and slots?

rajeshs
18th December 2007, 11:31
How to achieve this using signals and slots?

marcel
18th December 2007, 11:33
Connect the line edit's textChanged signal to a slot in your class and in there just assign the new text to the member variable.
The signal will get emitted each time the text changes.

rajeshs
18th December 2007, 11:37
Thank you for your valuable reply,

Is there any other straight mechanism to do this?

marcel
18th December 2007, 11:39
Thank you for your valuable reply,

Is there any other straight mechanism to do this?
Well, this is the most easiest one.
You could also try QSignalMapper if you have a lot of line edits, but it is also based on signal/slots.