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

QCursor bug in HighDPI

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Out of scope
    • Icon: P3: Somewhat important P3: Somewhat important
    • None
    • 5.8.0
    • GUI: Look'n'Feel
    • None
    • Windows 10, Qt 5.8

      When set new bitmap cursor for widget:

      Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget)
      {
          ui->setupUi(this);
      
          QBitmap cursorb(16, 16);
          cursorb.clear();
          {
          QPainter cpainter(&cursorb);
          cpainter.setPen(Qt::color1);
          cpainter.drawLine(7, 0,  7, 14);
          cpainter.drawLine(0, 7, 14,  7);
          }
      
          QCursor m_plotCursor = QCursor(cursorb, cursorb, 7, 7);
      
          setCursor(m_plotCursor);
      }
      

      It is look ugly with HighDPI set.

      QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
      

      I think that bug in this code (qwindowscursor.cpp):

      static HCURSOR createBitmapCursor(const QCursor &cursor, qreal scaleFactor = 1)
      {
       .....
      
      if (!qFuzzyCompare(scaleFactor, 1)) {
              const QSize scaledSize = (QSizeF(bbits.size()) * scaleFactor).toSize();
              bbits = bbits.scaled(scaledSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
              mbits = mbits.scaled(scaledSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
          }
      
      ...
      }
      

      Bug appear when resizing monochrome bitmap with Qt::SmoothTransformation.

        1. qtbug59866.zip
          2 kB
          Friedemann Kleint
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            kleint Friedemann Kleint
            keshav Konstantin Semenov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes