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 draw in QGraphicsView with the real size?
Qt 6.11 is out! See what's new in the release blog

How to draw in QGraphicsView with the real size?

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 472 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.
  • T Offline
    T Offline
    tankist
    wrote on last edited by
    #1

    I want to draw in QGraphicsView with the real size. For example, I need to draw a circle with diameter of 60 mm. So I add item to a scene:
    scene->addEllipse(-113, -113, 226, 226);
    My screen has DPI as 96, so 60 mm should be 226 pixels.
    But after I draw this circle I measured a circle on the screen and I found out it has 55 mm size only.

    What is the problem ?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Asperamanca
      wrote on last edited by
      #2

      First I would draw a circle of that size in a drawing program, and look if the actual size is 60mm across. Screen DPI is not always 100 % accurate, and the OS might also muddle up the waters.
      Have you checked the values in QScreen::logicalDotsPerInchX and logicalDotsPerInchY?

      On the graphic view side, you have multiple coordinate system transformations before you get to screen pixels:
      Item coordinates -> Scene coordinates -> View coordinates -> Screen coordinates.
      Any of these transformations could affect your outcome. So you need to check e.g. that the scene is displayed in the view at 100 %

      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