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. QGraphicsScene font calculation incorrect in Windows 11
Forum Updated to NodeBB v4.3 + New Features

QGraphicsScene font calculation incorrect in Windows 11

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

    My app has the option of using QPainter or QGraphicsScene to calculate the size of strings of characters, and display them in a box.

    In Windows 10 and previous versions, both work fine. In Windows 11, with QGraphicsScene the length of the characters as reported by Qt are understated, which results in the bounding box being too short:
    QGraphicsScene.png

    If I switch to QPainter in Windows 11, I get correct results:
    QPainter.png

    I am using Qt 5.15, and:

    QFontMetrics const font_metrics(QFont, QPaintDevice *device);
    font_metrics.boundingRect(QString qstr)
    

    I need to use QGraphicsScene for the faster performance.

    Has anyone else seen this problem? Any suggestions?

    I know there have been some changes in font metrics in Qt 6, but I'm not there yet, I need to get this to work in Qt 5 + Windows 11.

    UPDATE

    This is not a Windows 11 issue. It is caused by Display Scaling. At 100%, it looks OK. At 125%+, it protrudes. Further, the problem only occurs on the auxiliary (2nd) monitor, not on the main built-in display.

    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