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. QGraphicsView Coordinate system problem

QGraphicsView Coordinate system problem

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 377 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
    sref
    wrote on last edited by
    #1

    I have a problem with QGraphicsView coordinate system. I'm saving QGraphicsItem position and rotation in json file. I have changed the formula for delta x and y when I'm drawing an item (floorplan), but I'm setting the position as it was before, but now item is in different position. I'm setting the same values for scene rect as I had before to keep the coordinate system the same, but it doesn't work.

    When I output scene height and width, item position and rotation they are the same, but items are in different positions.
    Here is my code - https://gist.github.com/FaZeRs/1a2e32a34b3825ac1353db5c61d5b26b

    When loading old version http://i.imgur.com/Dy4nINL.png
    When saving old version to new and reloading - http://i.imgur.com/Z5WT7t1.png

    JKSHJ 1 Reply Last reply
    0
    • S sref

      I have a problem with QGraphicsView coordinate system. I'm saving QGraphicsItem position and rotation in json file. I have changed the formula for delta x and y when I'm drawing an item (floorplan), but I'm setting the position as it was before, but now item is in different position. I'm setting the same values for scene rect as I had before to keep the coordinate system the same, but it doesn't work.

      When I output scene height and width, item position and rotation they are the same, but items are in different positions.
      Here is my code - https://gist.github.com/FaZeRs/1a2e32a34b3825ac1353db5c61d5b26b

      When loading old version http://i.imgur.com/Dy4nINL.png
      When saving old version to new and reloading - http://i.imgur.com/Z5WT7t1.png

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by JKSH
      #2

      Hi, and welcome!

      @sref said in QGraphicsView Coordinate system problem:

      I'm saving QGraphicsItem position and rotation in json file. I have changed the formula for delta x and y when I'm drawing an item (floorplan), but I'm setting the position as it was before, but now item is in different position. I'm setting the same values for scene rect as I had before to keep the coordinate system the same, but it doesn't work.

      See https://doc.qt.io/qt-5//graphicsview.html#the-graphics-view-coordinate-system

      1. Do you save Item coordinates, Scene coordinates, or View coordinates?
      2. Do you load Item coordinates, Scene coordinates, or View coordinates?

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      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