Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Coordinate transformation problem with gestures and QGraphicsObject
Forum Updated to NodeBB v4.3 + New Features

Coordinate transformation problem with gestures and QGraphicsObject

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 897 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mickael.cruz
    wrote on last edited by
    #1

    Hello,

    I am working on a touchscreen app that displays objects in a QGraphicsScene. I have setup all the event handlers so that mouse and gestures are handled on the proper GraphicsObjects that are in the scene.
    However I have a coordinate problem : whenever I use the pinch gesture and to a translation, my object's movement is in another scale that the GraphicsScene.
    I tried to transform the gestures coordinate with mapToScene, mapFromScene, mapToParent, mapFromParent without getting it to work. I also tried retrieving the viewport's transform matrix and did the transformation, still without solving my problem.

    Here is my code :
    @
    void CustomGraphicsObject::gestureEvent(QGestureEvent event)
    {
    QGesture
    pinch = event->gesture(Qt::PinchGesture);
    if (pinch)
    {
    QPinchGesture* pGesture = dynamic_cast<QPinchGesture*>(pinch);
    QTransform invViewMatrix = scene()->views().first()->viewportTransform().inverted();

        QPointF diffTranslate = invViewMatrix.map(pGesture->centerPoint()) - invViewMatrix.map(pGesture->lastCenterPoint());
        emit Gestured(pos() + diffTranslate);
        setPos(pos() + diffTranslate);
    }
    

    }
    @

    Does anyone have an idea of what i am doing wrong?

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved