Are you sure ?? i saw Q3CanvasView and it is derived from QWidget ... isnt QCanvasView derived from QWidget ??But in the QanvasView the contentsMouseMoveEvent is the only function that can receive the mouseMoveEvent.
If it is derived, then u can override the mouseMoveEvent.... try it![]()
The QCanvasView is derived from QScrollView, the contentsMouseMoveEvent() is the member function of QScrollView. And also as the Qt documents example described, when you want to deal with mouseMoveEvent, mouePressEvent, mouseReleaseEvent etc. in the QCanvasView you can directly reimplement the contentsMouse****Event() which are all the member function of the QScrollView.
I'm not sure, but maybe you have to enable the mouse tracking on the viewport widget like in many corresponding situations you have to do in Qt4?
J-P Nurmi
What does it mean by "enable the mouse tracking on the viewport widget"?
What is viewport widget? I have only CanvasView wthin a QWidgetStack.
See QScrollView::viewport().
Try:
Qt Code:
viewport()->setMouseTracking(TRUE);To copy to clipboard, switch view to plain text mode
J-P Nurmi
should work....Qt Code:
viewport()->setMouseTracking(TRUE);To copy to clipboard, switch view to plain text mode
YES!That does work!
Thank you guys very much and best regards!
Could anybody are willing to compile the code and run it ?
When you run it ,you can click the Graphic button to switch to the QCanvasView. Then you hold the left mouse button dow and move it. Finally you can find the output
"The MouseMoveEvent has been received!" on the console. That means the QCanvasView receives the mouseMoveEvent correctly.
But when you just move the mouse without any button pressed down. There is no output on the console. So that means QCanvasView can not receive the mouseMoveEvent in the condition of no mouse button pressed down.
I hope that you can try it on practice. You will see the problem more clearly.
Thanks a lot!
Bookmarks