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. [Solved] QGraphicsItem->mapToScene missplacing QPointF
Forum Updated to NodeBB v4.3 + New Features

[Solved] QGraphicsItem->mapToScene missplacing QPointF

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 2.4k 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.
  • R Offline
    R Offline
    Rhadel
    wrote on last edited by
    #1

    !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.

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

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

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Rhadel
        wrote on last edited by
        #3

        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.

        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