Results 1 to 4 of 4

Thread: [Solved] QEvent::MouseMove problem

  1. #1
    Join Date
    Nov 2012
    Posts
    18
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default [Solved] QEvent::MouseMove problem

    I have an OpenGL 3.1 context drawing inside a generic QWidget promoted to a QGLWidget (not a QGraphicsView, I think). I need to find the mouse cursor position every time the mouse moves, so I can redraw some objects with updated coordinates. I've implemented the mouseMoveEvent event handler, but the problem is that it only registers if the mouse button is held down (clicking and dragging). This is not what I need; I have a seperate function called on mouse click, and I don't want it called just to detect the mouse moving.

    So my question is this: is there any way I can get an event for when the mouse is moved inside my Widget, even if the mouse button is not being held down?
    Last edited by fiodis; 16th November 2012 at 21:15.

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QEvent::MouseMove problem

    Why not read the docs?
    If mouse tracking is switched off, mouse move events only occur if a mouse button is pressed while the mouse is being moved. If mouse tracking is switched on, mouse move events occur even if no mouse button is pressed.
    http://doc.qt.nokia.com/latest/qwidg...eTracking-prop
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QEvent::MouseMove problem

    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  4. #4
    Join Date
    Nov 2012
    Posts
    18
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QEvent::MouseMove problem


    How did I miss that? It works perfectly, thank you!

Similar Threads

  1. QEvent::KeyPress problem, when will this event appear?
    By batileon in forum Qt Programming
    Replies: 11
    Last Post: 17th June 2011, 05:23
  2. QEvent problem
    By batileon in forum Qt Programming
    Replies: 3
    Last Post: 4th May 2009, 12:23
  3. Problem in MouseMove Event
    By Gamalof in forum Qt Programming
    Replies: 4
    Last Post: 17th June 2008, 20:24
  4. qevent problem
    By amulya in forum Qt Programming
    Replies: 2
    Last Post: 13th October 2006, 11:51
  5. Replies: 2
    Last Post: 8th August 2006, 15:09

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.