PDA

View Full Version : How to detect QT Mouse events outside a application window?



Danie
27th September 2013, 15:13
Hello,
I am trying to get the log when a mouse is moved outside a QT app window.
I have a QTGraphicsScene which zooms on mouse wheel.

Basically I am drawing a line from 1 point to other by left click using QPainter till the point on the scene I release on mouse down.
The problem happens when I zoom the scene and start drawing the line. But when the mouse cursor goes outside the app window
the line is drawn and no further detection of mouse happens even if I return back to the scene.

So I tried this :
void ClassName::mouseMoveEvent(QGraphicsSceneMouseEvent *event){


if (event->type() == QEvent::FocusOut) {
cout<<"----------///FocusOut -----------------------"<<endl;
}
}


I just need to know is their a way to detect mouse movements outside a QT app window. :confused:

Thankx in advance!!

anda_skoa
27th September 2013, 20:24
QWidget::leaveEvent(), QWidget::enterEvent()

Cheers,
_

Danie
7th October 2013, 19:10
I am stuck badly in this...
I cannot implement simultaneous mouse events in 2 separate class (as per above solution) as I don't which one will be fired first and how to then inform the second mouse event one about it.
I have a QGraphicsSceneMouseEvent running for a QGraphicsScene inside QGraphicsView. So I want to determine when a mouse event (from QGraphicsSceneMouseEvent) runs outside a QApplication window.
Isn't their any direct function call API for this determining whether the mouse move event goes outside app window?

anda_skoa
11th October 2013, 11:19
Isn't their any direct function call API for this determining whether the mouse move event goes outside app window?

Yes. QWidget::leaveEvent()

Cheers,
_