PDA

View Full Version : 's' is displayed instead of 'σ'



babygal
21st October 2010, 08:18
I wrote the following code to display 'σ' in my UI menu. But, instead 's' is shown in the UI menu.

Code :



private:
QMenu *visualsMenu;
QAction *visualsRadiusAct;

void createActions();
void createMenus();

void myClass::createActions()
{
visualsRadiusAct = new QAction(tr("&σ"), this);
}
void myClass::createMenus()
{
visualsMenu = menuBar()->addMenu(tr("&Visuals"));
visualsMenu->addAction(visualsRadiusAct);
}

Lykurg
21st October 2010, 08:27
You code looks strange. In createMenu you create an action and in createActions you create a menu:confused: Anyway, you probably have in stalled a translator? Try without tr(). Second, try to display σ without & and see if it is displayed correctly. Also make sure your file is encoded with utf8.

franco.amato
21st October 2010, 19:48
The action is created in createActions

SixDegrees
21st October 2010, 20:15
What is "&σ" supposed to do? If you're trying to insert a character literal, you need the ampersand followed by the character code, not the character.

Lykurg
21st October 2010, 21:35
The action is created in createActions
Ehm, thanks for that useful comment. If you would have compared the time stamp of my answer with the time stamp of the edit of babygal you would have noticed that the original comment was altered and corrected! Anyway, nice move of you babygal!

What is "&σ" supposed to do? If you're trying to insert a character literal, you need the ampersand followed by the character code, not the character.The & makes the action "selectable" with the keyboard. It underlines the character and thus it indicates which key to press to activate the action.

SixDegrees
21st October 2010, 21:37
Yes, but it doesn't allow you to insert non-ASCII characters into a string or display element. You typically have to use the character code for such characters.

Lykurg
21st October 2010, 21:46
Yes, but it doesn't allow you to insert non-ASCII characters into a stringHa, you are right, I always used that only which the designer which transforms it. One argument more, not using any tool when you want to understand things deeper:D

wysota
21st October 2010, 21:48
The code has to be directly accessible via keyboard. If there is no combination of keys that will output a sigma character then making it an accelerator doesn't make much sense.