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. How to map coordinates of QGraphicsScene to a PixmapItem that is moving and rotating (following a path)
Forum Updated to NodeBB v4.3 + New Features

How to map coordinates of QGraphicsScene to a PixmapItem that is moving and rotating (following a path)

Scheduled Pinned Locked Moved Unsolved General and Desktop
graphics scenegraphics viewcoordinatetransform
4 Posts 2 Posters 651 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.
  • S Offline
    S Offline
    Salman_1
    wrote on last edited by Salman_1
    #1
    This post is deleted!
    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet

      I think you are using the wrong class in your case.

      Check the Colliding Mice example.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      S 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet

        I think you are using the wrong class in your case.

        Check the Colliding Mice example.

        S Offline
        S Offline
        Salman_1
        wrote on last edited by Salman_1
        #3

        @SGaist
        Hello and thanks for the reply :)

        I just created a little code example to show my problem :)

        I looked at the mice example and i don't understand how the mouse is positioned.

            setRotation(rotation() + dx);
            setPos(mapToParent(0, -(3 + sin(speed) * 3)));
        

        Why is the x value always 0 but the mouse can move right and left?
        I also think that it is not quite comparable because i have given coordinates in the Scene my pixmap should follow while rotating.
        The mouse rotates randomly (seems to me like that) and positions itself on the Scene.
        I already tried mapFromParent. If i do that my Pixmap jitters and it doesn't follow the path.

        For a week i tried also Transforming (QTransform) and all that. Is their something else that i am missing?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          The trick of the mouse to rotate is that the rendering is rotated independently from the item itself.

          As for the movement, unless I am mistaken, it's always moving "horizontally" with respect to the item rotation rotation. Much like when you are walking, you are going forward, when you rotate you still go forward but with a different angle than before.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1

          • Login

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