Results 1 to 2 of 2

Thread: Shortcut key for context menu

  1. #1
    Join Date
    Oct 2007
    Posts
    39
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question Shortcut key for context menu

    Hi,

    I have a problem with context menu.....
    I have a context menu of copy past action handler on QTableWidget.

    Qt Code:
    1. QAction* copyAct = new QAction("&Copy", qTableWidgetObj);
    2. copyAct->setShortcut(tr("Ctrl+C"));
    To copy to clipboard, switch view to plain text mode 

    and for paste:
    Qt Code:
    1. QAction* pasteAct = new QAction("&Paste", qTableWidgetObj);
    2. pasteAct->setShortcut(QKeySequence::Paste);
    To copy to clipboard, switch view to plain text mode 

    I connect this with a slot as

    Qt Code:
    1. connect(copyAct, SIGNAL(triggered()), this, SLOT(slotCopy()));
    To copy to clipboard, switch view to plain text mode 

    I create context menu with

    Qt Code:
    1. qTableWidgetObj->setContextMenuPolicy(Qt::ActionsContextMenu);
    To copy to clipboard, switch view to plain text mode 

    Contextmenu gets creates and works fine if I press on one of the options of context menu.
    But when I press shortcut key on the table widget no slot is called.

    Please let me know your suggestions as how to implement it?
    Darshan

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Shortcut key for context menu

    Where do you call QWidget::addAction()?
    J-P Nurmi

Similar Threads

  1. Docked Widget Menu
    By Chuk in forum Qt Programming
    Replies: 6
    Last Post: 3rd July 2013, 15:12
  2. Button shortcut call an element in the menu
    By mourad in forum Qt Programming
    Replies: 5
    Last Post: 29th May 2008, 11:02
  3. MainWindow Menu bug in Qt 4.2.3?
    By No-Nonsense in forum Qt Programming
    Replies: 4
    Last Post: 11th March 2007, 12:47
  4. Tracking separators in a menu (insertSeparator)
    By PrimeCP in forum Qt Programming
    Replies: 4
    Last Post: 25th January 2006, 19:10

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.