Results 1 to 2 of 2

Thread: QShortcut SIGNAL must be of 0 arguments?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2010
    Posts
    65
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Windows

    Default QShortcut SIGNAL must be of 0 arguments?

    Is it possible for QShortcut (or some similar QObject) to send its code (Such as Qt::Key_G) as a SIGNAL to another widget's SLOT? It'd be nice if the other widget could have only one function to deal with all its keyboard events, as opposed to having one for each key.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: QShortcut SIGNAL must be of 0 arguments?

    Qt::Key is an enum which can be treated as an integer. So you simple can send an integer, or send the key directly:
    Qt Code:
    1. Q_SIGNALS:
    2. void myKeyPress(Qt::Key);
    3. //...
    4. Q_EMIT myKeyPress(Qt::Key_g);
    To copy to clipboard, switch view to plain text mode 

    EDIT: or use QKeyEvent as a wrapper.

Similar Threads

  1. timeout() signal to a slot with arguments
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 3
    Last Post: 11th June 2010, 14:48
  2. QShortcut not working
    By berinder in forum Qt Programming
    Replies: 0
    Last Post: 24th November 2008, 10:20
  3. QShortcut
    By SailinShoes in forum Qt Programming
    Replies: 4
    Last Post: 17th October 2008, 10:42
  4. QShortcut - doesn't work with Qt::Key_Return
    By naresh in forum Qt Programming
    Replies: 1
    Last Post: 12th April 2006, 12:00
  5. Signal arguments limit to ?
    By ucntcme in forum Qt Programming
    Replies: 5
    Last Post: 1st March 2006, 17: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
  •  
Qt is a trademark of The Qt Company.