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 change cordinate sistem in QGraphicsItem
QtWS25 Last Chance

How to change cordinate sistem in QGraphicsItem

Scheduled Pinned Locked Moved Unsolved General and Desktop
qt6qgraphicsitemqchart
4 Posts 2 Posters 593 Views
  • 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.
  • U Offline
    U Offline
    ugo_
    wrote on 26 Feb 2023, 17:01 last edited by
    #1

    I want to plot my custom item inside a chart.
    The cordinates of the components inside the object are in the chart's cordinate system, not the scene.
    How do I make this conversion? The example of my problem can be found in this link: https://stackoverflow.com/questions/75573360/qt-change-of-cordinates-for-qgraphicsitem

    P 1 Reply Last reply 26 Feb 2023, 17:42
    0
    • U ugo_
      26 Feb 2023, 17:01

      I want to plot my custom item inside a chart.
      The cordinates of the components inside the object are in the chart's cordinate system, not the scene.
      How do I make this conversion? The example of my problem can be found in this link: https://stackoverflow.com/questions/75573360/qt-change-of-cordinates-for-qgraphicsitem

      P Offline
      P Offline
      Pl45m4
      wrote on 26 Feb 2023, 17:42 last edited by Pl45m4
      #2

      @ugo_

      mapToScene(Point)
      mapFromScene(Point)
      mapToGlobal(Point)
      mapFromGlobal(Point)

      or the basic mapTo(someWidget, Point) / mapFrom(someWidget, Point)

      • https://doc.qt.io/qt-5/qgraphicsview.html#mapToScene

      Edit:
      After looking at your code, dont map your boundingRect to scene. It's in item coordinates.

      What do you get and what do you expect?


      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      U 1 Reply Last reply 27 Feb 2023, 00:00
      1
      • P Pl45m4
        26 Feb 2023, 17:42

        @ugo_

        mapToScene(Point)
        mapFromScene(Point)
        mapToGlobal(Point)
        mapFromGlobal(Point)

        or the basic mapTo(someWidget, Point) / mapFrom(someWidget, Point)

        • https://doc.qt.io/qt-5/qgraphicsview.html#mapToScene

        Edit:
        After looking at your code, dont map your boundingRect to scene. It's in item coordinates.

        What do you get and what do you expect?

        U Offline
        U Offline
        ugo_
        wrote on 27 Feb 2023, 00:00 last edited by
        #3

        @Pl45m4 I wanted to create my custom object to be displayed on the chart, and later possibly implementing a custom series for that object, messing with these conversion functions eventually made my code work, but I wanted an all rounded solution.

        P 1 Reply Last reply 27 Feb 2023, 02:22
        0
        • U ugo_
          27 Feb 2023, 00:00

          @Pl45m4 I wanted to create my custom object to be displayed on the chart, and later possibly implementing a custom series for that object, messing with these conversion functions eventually made my code work, but I wanted an all rounded solution.

          P Offline
          P Offline
          Pl45m4
          wrote on 27 Feb 2023, 02:22 last edited by
          #4

          Either I haven't figured out, what you are doing or it's complete nonsense (esp. the boundingRect)
          Maybe you can add the rest of your code and a screenshot of how your result looks.

          @ugo_ said in How to change cordinate sistem in QGraphicsItem:

          I want to plot my custom item inside a chart.

          Are you talking about QChart? So you have a QChart and want your item in your chart?!


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          1 Reply Last reply
          0

          1/4

          26 Feb 2023, 17:01

          • Login

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