my bad :(

I passed the "pos" attribute of a QGraphicsSceneMouseEvent, which is a QPointF, but QMouseEvent's ctor expects a QPoint. Now it works. Thanks!


On Wed, Sep 18, 2013 at 9:17 AM, Stas Boukarev <stassats@gmail.com> wrote:
Rujia Liu <rujia.liu@gmail.com> writes:

> Hi!
>
> 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:
>
> http://levelfour.googlecode.com/svn/branches/dev/app/gui/GraphicsView.cpp
>
> It uses the following trick:
>
> if (event->button() == Qt::MidButton) {
>   setDragMode(QGraphicsView::ScrollHandDrag);
>
>   // create a new mouse event that simulates a click of the left button
> instead of the middle button
>   QMouseEvent mouseEvent (event->type(), event->pos(), Qt::LeftButton,
> Qt::LeftButton, event->modifiers());
>   QGraphicsView::mousePressEvent(&mouseEvent);
> }
>
> 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.
>
> But when I tried in CommonQt I can only get "No applicable constructor
> QMouseEvent found for arguments..."
How does your code look like? I can construct a QMouseEvent perfectly
fine here.

(#_new QMouseEvent (#_QEvent::None) (#_new QPoint) (#_Qt::NoButton)
       (enum-or (#_Qt::LeftButton) (#_Qt::RightButton)) (#_Qt::NoModifier))
--
With best regards, Stas.