Results 1 to 3 of 3

Thread: how to combine keypress event and mousebuttonpress event?

  1. #1
    Join Date
    Apr 2007
    Posts
    16
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question how to combine keypress event and mousebuttonpress event?

    Hello Everyone,
    I want to know how to combine keypress event and mousebuttonpress event in QT4. My Gui Application requires a combination of ALT+leftMouseButton click and another with the right mouse button click.
    Both can individually be handled with respective signals but I can't figure out how to recognise a combination of the two.
    Awaiting an early reply.
    Best Regards
    Hildebrand

  2. #2
    Join Date
    Aug 2008
    Location
    Algarve, Portugal
    Posts
    287
    Thanks
    23
    Thanked 31 Times in 27 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60

    Default Re: how to combine keypress event and mousebuttonpress event?

    I have a sugestion, do something like this:


    Qt Code:
    1. void class::mousePressEvent(QMouseEvent *event)
    2. {
    3. bool bMousepress=true;
    4. }
    5.  
    6. void class::releaseEvent(QMouseEvent *event)
    7. {
    8. bool bMousepress=false;
    9. }
    10.  
    11. void class::keyPressEvent(QKeyEvent *event)
    12. {
    13. if (bMousepress && Qt::Key_Alt)
    14. {
    15. do_something();
    16. }
    17.  
    18. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: how to combine keypress event and mousebuttonpress event?

    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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.