Results 1 to 8 of 8

Thread: 's' is displayed instead of 'σ'

  1. #1
    Join Date
    Apr 2010
    Location
    Singapore
    Posts
    156
    Thanks
    47
    Qt products
    Qt4
    Platforms
    Windows

    Default 's' is displayed instead of 'σ'

    I wrote the following code to display 'σ' in my UI menu. But, instead 's' is shown in the UI menu.

    Code :

    Qt Code:
    1. private:
    2. QMenu *visualsMenu;
    3. QAction *visualsRadiusAct;
    4.  
    5. void createActions();
    6. void createMenus();
    7.  
    8. void myClass::createActions()
    9. {
    10. visualsRadiusAct = new QAction(tr("&σ"), this);
    11. }
    12. void myClass::createMenus()
    13. {
    14. visualsMenu = menuBar()->addMenu(tr("&Visuals"));
    15. visualsMenu->addAction(visualsRadiusAct);
    16. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by babygal; 21st October 2010 at 08:31.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: 's' is displayed instead of 'σ'

    You code looks strange. In createMenu you create an action and in createActions you create a menu 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.

  3. #3
    Join Date
    Nov 2007
    Location
    Italy
    Posts
    691
    Thanks
    59
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: 's' is displayed instead of 'σ'

    The action is created in createActions
    Franco Amato

  4. #4
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: 's' is displayed instead of 'σ'

    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.

  5. The following user says thank you to SixDegrees for this useful post:

    babygal (25th October 2010)

  6. #5
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: 's' is displayed instead of 'σ'

    Quote Originally Posted by franco.amato View Post
    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!
    Quote Originally Posted by SixDegrees View Post
    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.

  7. #6
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: 's' is displayed instead of 'σ'

    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.

  8. The following 2 users say thank you to SixDegrees for this useful post:

    babygal (25th October 2010), Lykurg (21st October 2010)

  9. #7
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: 's' is displayed instead of 'σ'

    Quote Originally Posted by SixDegrees View Post
    Yes, but it doesn't allow you to insert non-ASCII characters into a string
    Ha, 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

  10. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: 's' is displayed instead of 'σ'

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Map is not displayed from maps.google.com
    By abhilashajha in forum Qt Programming
    Replies: 2
    Last Post: 11th June 2009, 14:19
  2. image not displayed ...
    By sh123 in forum Qt Tools
    Replies: 4
    Last Post: 15th December 2008, 13:07
  3. Form not displayed in QT Designer 4
    By demorphica in forum Qt Tools
    Replies: 2
    Last Post: 15th July 2008, 00:34
  4. StatusTip remains displayed
    By emonette123 in forum Qt Programming
    Replies: 0
    Last Post: 4th April 2008, 16:32
  5. SplashScreen isn't displayed
    By Salazaar in forum Newbie
    Replies: 26
    Last Post: 27th June 2007, 21:14

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.