Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-86170

QLabel::setPixmap appears truncated under high screen device pixel ratio

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • 5.15.2
    • 5.11.3
    • None
    • linux x11
    • Linux/X11
    • eb98bed4e76bb0fa6bad8474f2f370334cb70f6c (qt/qtbase/dev) dbffdb66544dd0c74a17b92487a79f5781c85057 (qt/qtbase/5.15)

    Description

      When the device pixel ratio is greater than 1,  use QLabel::setPixmap,  the content of one pixel on the right and bottom side of the QLabel will be truncated

      The following code is an example of mine.

          QApplication app(argc, argv);
          QWidget w;
          QHBoxLayout hlayout;
          QPixmap pix(98, 98);
          QPainter p(&pix);
          
          pix.fill(Qt::black);
          p.setRenderHint(QPainter::Antialiasing);
          p.setBrush(Qt::gray);
          p.setPen(Qt::NoPen);
          p.drawEllipse(0, 0, pix.width(), pix.height());
      
          w.setLayout(&hlayout);
      
          QLabel label1;
          pix.setDevicePixelRatio(1.25);
          label1.setPixmap(pix);
          hlayout.addWidget(&label1);
      
          QLabel label2;
          pix.setDevicePixelRatio(1);
          label2.setPixmap(pix);
          hlayout.addWidget(&label2);
      
          w.setPalette(QPalette(Qt::red));
          w.show();
      

      Compare the left side and the upper side, and you'll see the right side and the lower side are clearly truncated

      Attachments

        1. bug.png
          bug.png
          24 kB
        2. qtbug86170.jpg
          qtbug86170.jpg
          8 kB
        3. qtbug86170.zip
          2 kB
        4. Your screenshot.png
          Your screenshot.png
          8 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              sorvig Morten Sørvig
              chen_bin Chen Bin
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes