Results 1 to 2 of 2

Thread: QAction shortcut

  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QAction shortcut

    Hi,

    Qt Code:
    1. m_pqAction = new QAction(tr("Lock"),this);
    2. m_pqAction ->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_7));
    3. connect(m_pqAction ,SIGNAL(triggered()),this,SLOT(lock()));
    To copy to clipboard, switch view to plain text mode 
    The connect returns true but the SLOT is never called.
    Have I to add the action on a QToolBar to let it work? The other actions added to the QToolBar work well but this action have to not be shown.

    Thanks,
    Òscar Llarch i Galán

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QAction shortcut

    you need to add the action to a widget, otherwise it won't work.
    Try calling QAction::setVisible() to hide it afterwards (if you add it to the toolbar). You can add it to the window itself, then you dont have to hide it, btw.

    HTH

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

    ^NyAw^ (3rd December 2009)

Similar Threads

  1. Invoke QCompletion on keyboard shortcut
    By aspidites in forum Qt Programming
    Replies: 0
    Last Post: 30th August 2009, 10:32
  2. Having some QObject problems
    By Barvik in forum Qt Programming
    Replies: 7
    Last Post: 13th November 2008, 04:29
  3. adding QAction to QDialog is not working
    By sanjayshelke in forum Qt Programming
    Replies: 3
    Last Post: 13th August 2008, 09:39
  4. uic3 QAction problem
    By batileon in forum Qt Programming
    Replies: 0
    Last Post: 16th June 2008, 10:35
  5. Strange shortcut problem
    By blukske in forum Qt Programming
    Replies: 0
    Last Post: 13th March 2007, 10:26

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
  •  
Qt is a trademark of The Qt Company.