Results 1 to 3 of 3

Thread: Shortcuts for QActions...

  1. #1
    Join Date
    Jul 2009
    Posts
    42
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Question Shortcuts for QActions...

    Hello,
    there probably are similar questions to the ones I am about to ask somewhere in the depths of the forum (which I have not found yet, at least nothing that will help me).

    I have the following Problems with setting shortcuts for QActions:

    1. I have a Widget that is built with 2 QLables and 1 QLineEdit. Its suposed to be a numeric indicator so most of the time it should be read only. But i want to be able to enter an editing mode when the user presses "F2" (or any other keysequence...)

    So I did the following in my widget:
    Qt Code:
    1. ...
    2. QAction *editAction= new QAction(this);
    3. editAction->setShortcut(QKeySequence(Qt::Key_F2));
    4. editAction->setShortcutContext(Qt::WidgetWithChildrenShortcut);
    5.  
    6. connect(editAction,SIGNAL(triggered())),this,SLOT(setEditable()));
    7. ...
    8. void Display::setEditable()
    9. {
    10. valueDisp->setReadonly(false);
    11. }
    To copy to clipboard, switch view to plain text mode 

    2. I have a MDI subwindow, with a custom texteditor widget in it. Here i have an action that removes the Frame (In order to lock the editor in position)
    the action can be called from the mdi system menu, which cant be reached when there is no frame, so i want the Action to have a shortcut eg. "F6".
    I have created the Action and given it such a shortcut, but it wont trigger.


    I am pretty sure my problems have something to do with the focus when the shortcut is used, but i am not sure how i can correct this.

    Can anyone guide me to the answer?

    Thank you for reading

    Eric

  2. #2
    Join Date
    Sep 2009
    Posts
    140
    Thanks
    4
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Shortcuts for QActions...

    So you need to trigger an action of a widget that is not focused?
    ( but how do you know which window needs to be reset on?)

    Maybe you can manage your action one step higher in your widget hierarchy, to trigger it on or off,

    Or maybe you can set your shorcut as Qt::ApplicationShortcut or Qt::WindowShortcut instead of Qt::WidgetWithChildrenShortcut

  3. #3
    Join Date
    Jul 2009
    Posts
    42
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Shortcuts for QActions...

    I am trying to handle the shortcuts from the parent, while the child has focus...

    I did try using Qt::WidgetWithChildrenShortcut (seemed right to me from the documentation) to no effect...

Similar Threads

  1. Cut/Copy/Paste overrider shortcuts
    By mchara in forum Qt Programming
    Replies: 11
    Last Post: 2nd January 2008, 09:31
  2. Key shortcuts for not visible widgets
    By trskel in forum Qt Programming
    Replies: 1
    Last Post: 26th March 2007, 10:02
  3. Replies: 5
    Last Post: 23rd February 2007, 10:23
  4. Creatin Key Pad shortcuts
    By Kapil in forum Newbie
    Replies: 1
    Last Post: 19th May 2006, 05:50
  5. Replies: 1
    Last Post: 18th March 2006, 16:37

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.