Results 1 to 8 of 8

Thread: QShortcut not always working

Threaded 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 QShortcut not always working

    I use QShortcut inside a widget to close the widget by pressing esc.

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

    there are 2 differnet ways for a user to open the widget. in the first way everything works fine, the secound the shortcut doesn't work.

    in the paint -event of the widget i put a debug-message to detect which widget as the focus:

    qDebug() << "focus widget: " << QApplication::focusWidget() << focusWidget() << shortcut_esc->isEnabled() << local->hasFocus() << isActiveWindow() << hasFocus();

    the output is the same for both ways, so i think the focus is positioned right.
    when the user clicks anywhere in widget, the shortcut works fine even for the secound way.

    am i missing something?

    where is the difference between clicking on a widget and use the setFocus() Member?
    Last edited by jörg; 31st May 2011 at 13:41.

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.