[Solved] QGraphicsItem->mapToScene missplacing QPointF



  • !http://s22.postimg.org/lyqgxvvrl/arrow.png(Arrow)!

    As you can see at the image, I'am trying to port the arrowhead point coordinates to GraphicsScene coordinates. I make a line with the same distance to the center, the point already ported in Scene coordinates:

    @
    //Item context (Custom QGraphicsItem).
    QPointF drawer = this->getCableArrowPoint();
    drawer = this->mapToScene(drawer);
    QLineF line2(QPointF(drawer.x() - 50, drawer.y()), QPointF(drawer.x() +50, drawer.y()));
    scene()->addLine(line2);
    @

    As result, you can see the line is missplaced, a bit to the right where expected.

    In fact, my problem is a bit complicated than that, but I'm trying to simplifie to this one I'm posting, because I think both problems have the same origin.

    Why item->mapToScene is porting the item's point to an unexpected place (further to the right) in scene?

    Something similar is happening while mapping to scene a QPainterPath.

    Thank you.


  • Moderators

    what does the method getCableArrowPoint() exactly do?
    Is the cableArrow item a child-item of "this" item?



  • Thank you for your fast reply, raven-worx.

    Again my fault, arrow->setParentItem (this) solved it. I never forget this step, but now :(

    Thank you, and sorry for my newbie questions.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.