PDA

View Full Version : Possible to use an ampersand (&) character in a QCheckBox?



dobedidoo
7th June 2010, 15:26
Hi,


Is there any way to include an ampersand (&) character in a QCheckBox text? For example I want to do something like this, but having the "&" to actually show up "as is" in my application:

QCheckBox* myCheck = new QCheckBox("Include Comments & Notes");With the above code the "&" will just be ignored.

I've tried to do this in several ways but haven't succeeded. I know that a work-around could be to create an "empty" checkbox and just add a QLabel after, but I'd prefer to just use the QCheckBox, if possible.

Thanks!

ChrisW67
8th June 2010, 00:40
The ampersand is used as a marker for the QCheckbox shortcut key (described in the docs). In your example you are making the space following the ampersand a shortcut. Try escaping the ampersand with a second one:


QCheckBox* myCheck = new QCheckBox("Include Comments && Notes");