PDA

View Full Version : How do I create an Option button like VB?Pressed then down, pressed again then up.



yyiu002
1st October 2010, 05:14
At Visual Basic 6 I can create several option buttons, if one pressed, it is in down state, press it again, it pops up.

Is there a way in QT can do this?

tbscope
1st October 2010, 06:27
A QToolButton will do what you want I guess.

marcvanriet
1st October 2010, 12:53
Hi,

Set the 'checkable' property. Even normal buttons (like a QPushButton) can have this property set.

Regards,
Marc

Urthas
1st October 2010, 20:42
Set the 'checkable' property.

Quick note to the OP, you can use either
setProperty("checkable", QVariant(true)); or
setCheckable(true); to do this. I guess some properties are so frequently useful that convenience functions have been added. :)

berlinud
2nd October 2010, 03:55
the checkable property is definitely right

yyiu002
4th October 2010, 02:02
One more question, is it possible to have text automatic wrapped to next line if button is narrowed.

yyiu002
4th October 2010, 04:19
Found how to do it, add "\n" in between text.