View Full Version : ampersand showing in QLabel
dave
4th November 2006, 23:45
hello
In QLabel instead of showing a letter underlined, I see the ampersand sign.
for example:
QLineEdit *initiator = new QLineEdit(this);
QLabel *initiatorL = new QLabel("&initiator:", this);
initiator->setBuddy(initiatorL)
Show in my widget as: "&initiator:" with the ampersand.
How can I make Qlabel display it correctly, as an underlined letter?
jacek
4th November 2006, 23:50
initiator->setBuddy(initiatorL)
Shouldn't it be:
initiatorL->setBuddy(initiator)?
dave
4th November 2006, 23:55
You're right, of course jacek.
should be:
QLineEdit *initiator = new QLineEdit(this);
QLabel *initiatorL = new QLabel("&initiator:", this);
initiatorL->setBuddy(initiator)
Any idea about the problem?
jpn
5th November 2006, 00:09
Read notes about mnemonic in QLabel::setBuddy().
Edit: Hmm, just ignore this.. I definitely need some sleep :)
dave
5th November 2006, 12:43
I think I found out the reason. Apparently I called setbuddy before setting up the associated widget. Like this:
QLabel *initiatorL = new QLabel("&initiator:", this);
initiatorL->setBuddy(initiator);
QLineEdit *initiator = new QLineEdit(this);
Changing line 2 with 3 fixed the problem. Really should have noticed it...
But now I have a weird problem. This is the code:
initL = new QLabel("&Initiator");
init = new QLineEdit();
initL->setBuddy(init);
init->setValidator(new LSEdgeValidator(init));
ruleFL = new QLabel("Production &F");
ruleF = new QLineEdit();
ruleFL->setBuddy(ruleF);
ruleF->setValidator(new LSEdgeValidator(ruleF));
rulefL = new QLabel("Production &f");
rulef = new QLineEdit();
rulefL->setBuddy(rulef);
rulef->setValidator(new LSEdgeValidator(rulef));
And the problem is:
First: the underline won't show up unless I press the ALT key. Second: Once I do - the underline shows on every QLabel apart from initL - the first QLabel I set up in the code. If I change initL place in the code and put ruleFL first - then ruleFL won't show underlined.
I'm confused.
jacek
5th November 2006, 13:02
First: the underline won't show up unless I press the ALT key.
This is a windows "feature", probably you can disable it somewhere (for example in theme settings).
sunil.thaha
7th November 2006, 06:15
To add to what Jacek said. Here is a Quote :rolleyes:
Any sufficiently disguised bug is indistinguishable from a feature. -- Rich Kulawiec
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.