Results 1 to 6 of 6

Thread: Hide shorcut text of QMenu Action

  1. #1
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Angry Hide shorcut text of QMenu Action

    I ve looking for an answer all over the internet but i dont seem to get one...

    i ve tried changing the stylesheet but i think there's no option to do what i want

    in the documentation i ve read that the action has: (icon-text-shorcut text), so what i want is to disable/hide the shorcut text

    thanks!

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Hide shorcut text of QMenu Action

    Well, we could could guess what you are trying to achieve, what you are doing, and what the result is... or you could show us with a screen shot or a small, compilable example that displays the problem and what you have tried.

  3. The following user says thank you to ChrisW67 for this useful post:

    KillGabio (16th January 2012)

  4. #3
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Hide shorcut text of QMenu Action

    lol, ok.. i want Ctrl+F to disappear :/

    problem.JPG

  5. #4
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Hide shorcut text of QMenu Action

    What is that?
    Is it a QPushButton, QToolButton, QMenu or something else?
    Some code how you construct that element would be nice.

    Getting rid of that text will be different depending on what it is.
    General idea would be not to add the action to that item but to something else, ie parent widget.
    Action will still be triggered but the text will not be displayed.

  6. #5
    Join Date
    Jan 2012
    Location
    Argentina
    Posts
    167
    Thanks
    33
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Hide shorcut text of QMenu Action

    hi, sorry for the delay.

    it`s an QAction from the QMenu->QMenuBar->QMainWindow

    i just did that with the QDesigner so the mainwindow implements everything

  7. #6
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Hide shorcut text of QMenu Action

    Ok, I have no idea how to hide the shortcut text from action without disabling it (the shortcut).
    Other approach could be not to set the shortcut on the action but add it (the shortcut) to the main window, something like this:
    Qt Code:
    1. MainWindow::MainWindow( QWidget* parent )
    2. : QMainWindow( parent )
    3. {
    4. QMenu* m = this->menuBar()->addMenu( "test" );
    5. m->addAction( "close", this, SLOT( close() ) ); // action will not have a shortcut but will still do the right thing when clicked
    6.  
    7. QShortcut* s = new QShortcut( Qt::CTRL + Qt::Key_Q, this );
    8. connect( s, SIGNAL( activated()), a, SLOT( trigger() ) ); // shortcut is not visible but will trigger the action which in trun will do the right thing
    9. }
    To copy to clipboard, switch view to plain text mode 
    You can't do that from the designer though.

Similar Threads

  1. How to get toggle action text?
    By sudhansu in forum Qt Programming
    Replies: 4
    Last Post: 29th May 2012, 11:57
  2. problems on the QMenu hide
    By xiongxiongchuan in forum Qt Programming
    Replies: 1
    Last Post: 31st August 2010, 09:42
  3. Hide and Show QMenu
    By febil in forum Qt Programming
    Replies: 3
    Last Post: 25th March 2009, 09:31
  4. QMenu still highligheted after action fired in mac
    By berinder in forum Qt Programming
    Replies: 2
    Last Post: 1st September 2008, 19:53
  5. get Text from Popupmenu action
    By raphaelf in forum Newbie
    Replies: 6
    Last Post: 11th October 2006, 15:24

Tags for this Thread

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.