Results 1 to 8 of 8

Thread: QShortcut not always working

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QShortcut not always working

    no ideas anyone?

  2. #2
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    131
    Thanks
    11
    Thanked 16 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QShortcut not always working

    Do you get a message on the console if you click the shortcut multiple times saying that the shortcut ambiguous?

    By the way its really hard to image what you are doing without real code (or at least a shortcut)

  3. #3
    Join Date
    Jul 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QShortcut not always working

    i use the following shortcuts:

    shortcut_esc = new QShortcut(this);
    shortcut_esc->setKey(Qt::Key_Escape);
    connect(shortcut_esc,SIGNAL(activated ()),PlayerExtraScreen::instance(),SLOT( showListView() ));

    shortcut_pgup = new QShortcut(this);
    shortcut_pgup->setKey(Qt::Key_PageUp);
    connect(shortcut_pgup,SIGNAL(activated ()),this,SLOT( backItem() ));
    connect(shortcut_pgup,SIGNAL(activatedAmbiguously ()),this,SLOT( backItem() ));

    shortcut_pgdown = new QShortcut(this);
    shortcut_pgdown->setKey(Qt::Key_PageDown);
    connect(shortcut_pgdown,SIGNAL(activated ()),this,SLOT( nextItem() ));
    connect(shortcut_pgdown,SIGNAL(activatedAmbiguousl y()),this,SLOT( nextItem() ));

    as you can see a also use the Ambigously Signal for testing. but the shortcvut is not ambiuge, i already checked that.
    it seems the the key-pressed event is 'swallowed' by an other widget (cause of the fakt that after i clicked somewhere in the app, the shortcut works).
    and that is the point wich i do not understand:
    the widget is the active widget (the one with the focus) - so why does it get the key event one the first way and not on the second. there must be something beside the attribut 'hasFocus' that the shortcut depends on. what else can it be???? please help

  4. #4
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    131
    Thanks
    11
    Thanked 16 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QShortcut not always working

    What is "this" in the QShortcut Contstructor?

  5. #5
    Join Date
    Jul 2010
    Posts
    15
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QShortcut not always working

    the code snipped is part of the constructor of the detailview class, whitch is the parent of the shortcut.
    so the 'this' pointer is ther instance of the detailview containing the shortcut

Similar Threads

  1. QShortcut not work!
    By leeeryan in forum Newbie
    Replies: 1
    Last Post: 16th December 2010, 09:27
  2. QShortcut SIGNAL must be of 0 arguments?
    By Wasabi in forum Newbie
    Replies: 1
    Last Post: 17th August 2010, 21:26
  3. QShortcut not working
    By berinder in forum Qt Programming
    Replies: 0
    Last Post: 24th November 2008, 10:20
  4. QShortcut
    By SailinShoes in forum Qt Programming
    Replies: 4
    Last Post: 17th October 2008, 10:42
  5. QShortcut - doesn't work with Qt::Key_Return
    By naresh in forum Qt Programming
    Replies: 1
    Last Post: 12th April 2006, 12:00

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.