Results 1 to 10 of 10

Thread: mouseMoveEvent problem

  1. #1
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default mouseMoveEvent problem

    I want to get mouse cursor position instantaneously on a widget which is in a graphicsproxywidget; but the mouseMoveEvent is not being called anytime. I put a qDebug inside the event, nothing is written on the console when i run the application. I reimplemented the event in the proxywidget class' definition.

    Qt Code:
    1. void panelProxy::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
    2. {
    3. qDebug("mousevent");
    4. }
    To copy to clipboard, switch view to plain text mode 

    What may be the problem?

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: mouseMoveEvent problem


  3. #3
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: mouseMoveEvent problem

    No, i didnt set QGraphicsItem::setAcceptHoverEvents() true; i can use hover events, there is no problem with them. But mouseMoveEvent doesn't work...

  4. #4
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: mouseMoveEvent problem

    The point is: you won't get mouseMoveEvents unless you set the item to accept hover events.

  5. #5
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: mouseMoveEvent problem

    I ve just tried "setAcceptHoverEvents(true)"; that didnt make any difference..What may be else?

  6. #6
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: mouseMoveEvent problem

    Now, Ive tried to implement the event inside of the widget, not inside of the proxywidget..It works partially know...

    Qt Code:
    1. void screenWidget::mouseMoveEvent(QMouseEvent *event)
    2. {
    3. qDebug("mouseevent in widget");
    4.  
    5. }
    To copy to clipboard, switch view to plain text mode 

    I moved the cursor for 30 seconds on the screen;but there were just 2 events I could see on the console! What is that know Shouldn't that event be called every milliseconds I move the mouse?

  7. #7
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mouseMoveEvent problem

    for widgets u need QWidget::setMouseTracking to be true

  8. #8
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: mouseMoveEvent problem

    setMouseTracking is already set true. The question is why is the event being called sometimes;but sometimes not?

  9. #9
    Join Date
    Dec 2007
    Location
    London
    Posts
    206
    Thanks
    40
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android

    Default Re: mouseMoveEvent problem

    I think, i got the problem. I should setMouseTracking(true) for central widget and all child widgets. Isn't there any direct way to make setMouseTracking(true) for all widgets on the scene?

  10. #10
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: mouseMoveEvent problem

    You can set the mouse tracking on the parent widgets if ther is one item in the scene, or iterate on top child items and set it manually

Similar Threads

  1. Problem in MouseMoveEvent
    By aamer4yu in forum Qt Programming
    Replies: 18
    Last Post: 3rd December 2015, 11:20
  2. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  3. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  4. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

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.