Results 1 to 5 of 5

Thread: catch (spaceBar+mouse move) event

  1. #1
    Join Date
    Jun 2013
    Location
    Bangalore
    Posts
    27
    Thanks
    7
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Post catch (spaceBar+mouse move) event

    hi,
    i want to drag my scene, by dragging the mouse on scene & hold space bare (press and hold space bar + drag mouse) .
    what is the best place to check this combination and how can i check this condition .
    i have QGraphicsView and QGraphicsScene on QMainwindow .

    my idea is as below

    QGraphicsView:: mouseMoveEvent(QMouseEvent* f_event)
    {
    If(space bar is pressed and hold) // here how can I check key press event
    {
    Here we will set drag mode; //QGraphicsView:: ScrollHandDrag
    }
    }


    Thanks in advance :-)
    Last edited by prasad.ece2; 28th November 2013 at 15:44. Reason: updated contents

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: catch (spaceBar+mouse move) event

    Set a flag when you receive a keyPressEvent() for Qt::Key_Space.
    Clear the flag when you get a keyReleaseEvent() for Qt::Key_Space.
    If the flag is set when you enter the mouseMouseEvent()...

  3. #3
    Join Date
    Jun 2013
    Location
    Bangalore
    Posts
    27
    Thanks
    7
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: catch (spaceBar+mouse move) event

    thank you ChrisW67 .

    is there any other way to check only current event, rather than setting bool ?

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: catch (spaceBar+mouse move) event

    No. The key press event is over by the time the mouse event occurs and there is no isKeyDownNow() function.

  5. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: catch (spaceBar+mouse move) event

    i want to drag my scene, by dragging the mouse on scene & hold space bare (press and hold space bar + drag mouse) .
    This is very strange behavior for a user interface. Why don't you do something that is more normal (and that you can test for in a mouse event) like Shift + mouse drag? You can use the QMouseEvent::modifiers() method to check for the shift key.

Similar Threads

  1. Replies: 3
    Last Post: 7th January 2012, 08:38
  2. catch global mouse press event
    By nick85 in forum Newbie
    Replies: 3
    Last Post: 15th June 2011, 13:37
  3. mouse move event filtering in PyQt4
    By lucaf in forum Qt Programming
    Replies: 1
    Last Post: 4th April 2009, 14:53
  4. Replies: 2
    Last Post: 4th August 2007, 04:31
  5. Mouse Move Event
    By merry in forum Newbie
    Replies: 5
    Last Post: 3rd June 2007, 06:26

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.