PDA

View Full Version : checkbox



fluefiske
5th October 2010, 22:20
Hello All,

I am a really newbie and try some stuf in Qt 4.7, now I would like 2 checkboxes which are just able to be checked one at a time. This is did succesfull, now I would like that one checkbox is checked then a certain value appears for example in a line edit field which I added to my ui file. And if the other checkbox is checked then another vsalue appears.

I simple don't no how to do this.

Thank you all,

André

Lykurg
5th October 2010, 22:27
Hi,
read about signal and slots in the documentation. That is all you need. Then simply connect the checkbox checked signal to a custom slot where you alter e.g. the text of a line edit.

ChrisW67
5th October 2010, 22:32
You would typically use radio buttons (QRadioButton) to get the mutually exclusive "checkboxes". In most GUIs check boxes (QCheckBox) operate independently of each other (although not always).

You need to connect the QRadioButton clicked(bool) signal, or the QCheckBox stateChanged(int) signal, to a slot or slots that affect the text in the QLineEdit. Exactly what is done in the slot(s) depends on what you want in the line edit.

D'oh! Beaten to the punch by Lykurg (again!)

Lykurg
5th October 2010, 22:41
D'oh! Beaten to the punch by Lykurg (again!)I am sorry;) (I was only faster because my answer was very fast and not so detailed as yours.)