PDA

View Full Version : mouseMoveEvent problem



yagabey
27th November 2008, 17:18
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.


void panelProxy::mouseMoveEvent(QGraphicsSceneMouseEven t *event)
{
qDebug("mousevent");
}

What may be the problem?

caduel
27th November 2008, 17:34
have you set QGraphicsItem::setAcceptHoverEvents() to true?

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

caduel
27th November 2008, 17:57
The point is: you won't get mouseMoveEvents unless you set the item to accept hover events.

yagabey
27th November 2008, 18:05
I ve just tried "setAcceptHoverEvents(true)"; that didnt make any difference..What may be else?

yagabey
27th November 2008, 18:33
Now, Ive tried to implement the event inside of the widget, not inside of the proxywidget..It works partially know...


void screenWidget::mouseMoveEvent(QMouseEvent *event)
{
qDebug("mouseevent in widget");

}

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:confused: Shouldn't that event be called every milliseconds I move the mouse?

aamer4yu
28th November 2008, 04:35
for widgets u need QWidget::setMouseTracking to be true

yagabey
28th November 2008, 10:59
setMouseTracking is already set true. The question is why is the event being called sometimes;but sometimes not?

yagabey
28th November 2008, 11:37
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?

aamer4yu
28th November 2008, 12:51
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