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. High DPI Support QPainter::drawText
Forum Updated to NodeBB v4.3 + New Features

High DPI Support QPainter::drawText

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

    Hi Guys,

    I have a problem with HighDPI-Support and drawing text into an image with a painter.
    HighDPI-Support is activated (before the QApplication is started) via

    QApplication::setAttribute( Qt::AA_EnableHighDpiScaling );
    QApplication::setAttribute( Qt::AA_UseHighDpiPixmaps );
    

    The image and the text is drawn as follows:

    QPixmap image = source->scaledToWidth( newWidth, Qt::SmoothTransformation );
    ...
    
    QPainter painter( &image );
    painter.setRenderHint( QPainter::TextAntialiasing );
    painter.setRenderHint( QPainter::Antialiasing );
    painter.drawText( rect, Qt::AlignCenter, str );
    
    ui.label_image->setPixmap( image );
    

    The result is an aliased text in the image (this is on a 4K monitor).

    highdpi.png

    If I disable high DPI support, the text in the image is better, especially antialiazed (this is on a FullHD Monitor).

    lowdpi.png

    As I write this post, I noticed that not only the text, but also the image itself (HighDPI version) is aliased.
    Does anybody know why?

    regards
    Oliver

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

      Hi,

      Sorry I don't have a direct answer for that. In any case what version of Qt are you using ? There's been quite some work on the HighDPI side in the latest releases which may behave better.

      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
      0
      • S Offline
        S Offline
        stvokr
        wrote on last edited by
        #3

        I'm using Qt 5.12.5.

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

          You should try with Qt 5.14.1 to see if it as improved.

          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
          • S Offline
            S Offline
            stvokr
            wrote on last edited by
            #5

            Qt 5.14.1 has the same problem.

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

              Did you check the bug report system ?

              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
              0

              • Login

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