[Qt-interest] need to define mousePressEvent to make mouseMoveEvent work?????
Malyushytsky, Alex
alex at wai.com
Wed Nov 4 03:58:19 CET 2009
Does not Qt documentation answer it?
"mouseTracking : bool
This property holds whether mouse tracking is enabled for the widget.
If mouse tracking is disabled (the default), the widget only receives mouse move events when at least one mouse button is pressed while the mouse is being moved.
If mouse tracking is enabled, the widget receives mouse move events even if no buttons are pressed.
Access functions:
bool hasMouseTracking () const
void setMouseTracking ( bool enable )
.......................
void QWidget::mouseMoveEvent ( QMouseEvent * event ) [virtual protected]
This event handler, for event event, can be reimplemented in a subclass to receive mouse move events for the widget.
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.
QMouseEvent::pos() reports the position of the mouse cursor, relative to this widget. For press and release events, the position is usually the same as the position of the last mouse move event, but it might be different if the user's hand shakes. This is a feature of the underlying window system, not Qt.
See also setMouseTracking(), mousePressEvent(), mouseReleaseEvent(), mouseDoubleClickEvent(), event(), QMouseEve
"
Regards,
Alex
-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Yifei Li
Sent: Tuesday, November 03, 2009 6:50 PM
To: qt-interest
Subject: [Qt-interest] need to define mousePressEvent to make mouseMoveEvent work?????
Hi,
I noticed this recently:
I add a custome widget to QGraphicsScene and implemented mouseMoveEvent for the custome QWidget class.
However, I need to define mousePressEvent(even its body is EMPTY) for mouseMoveEvent to work. Otherwise, my custome QWidget would not receive mouse move event.
Could someone tell me why is that?
Thanks
Yifei
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
"This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you."
"Please consider our environment before printing this email."
More information about the Qt-interest-old
mailing list