<div dir="ltr"><div><div><div><div><div>Hi!<br><br>How to create a manual QMouseEvent? I wanna do this because I want to implement canvas dragging on midbutton. I'm referring to this code:<br><br><a href="http://levelfour.googlecode.com/svn/branches/dev/app/gui/GraphicsView.cpp">http://levelfour.googlecode.com/svn/branches/dev/app/gui/GraphicsView.cpp</a><br>
<br></div>It uses the following trick:<br><br>if (event->button() == Qt::MidButton) {<br> setDragMode(QGraphicsView::ScrollHandDrag);<br><br> // create a new mouse event that simulates a click of the left button instead of the middle button<br>
QMouseEvent mouseEvent (event->type(), event->pos(), Qt::LeftButton, Qt::LeftButton, event->modifiers());<br> QGraphicsView::mousePressEvent(&mouseEvent);<br>}<br><br></div>That is, when midbutton is down, set the dragging mode and simulate a leftbutton press. The mouse release handler is similar and is omitted here.<br>
<br></div>But when I tried in CommonQt I can only get "No applicable constructor QMouseEvent found for arguments..."<br><br></div>Using "describe", I can see that the last two parameters should be QFlags<>, which is a template class. However there are no setXXX methods, so I cannot make changes to the current mouse event. Is there a workaround?<br>
<br></div>- Rujia<br><br></div>