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

[MacOSX] QIcon doesn't display properly on HighDPI screen when one screen is HighDPI and one is not

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.6.0 Beta
    • 5.3.0 RC1
    • GUI: Painting
    • None
    • Mac OSX 10.9.2
    • 74a2e29705c283a6f52cf007a14a552cf529d051 8793ad8175191db9abfb9f034017b9a8fe095f5c

    Description

      I have two 24" monitors whose native resolution is 1900x1080.

      If I run the attached test application, the two icons displayed in the dialog the application creates look correct (test_nohighres_monitor.png).

      If I then change my left monitor's resolution to simulate a retina display (960x540 HiDPI) and restart the application, the icons look correct when the application is on the left (simulated HiDPI) monitor (test_highres_monitor.png) but if I move the application to the right, native resolution monitor, some icons look very bad (test_lowres_monitor.png, focus on the icon on right).

      As you can see in the test application, for each image I have a regular version and a @2x version.

      I would expect that when I move the application from the HiDPI monitor to the regular DPI monitor, the icon file being displayed would go from the @2x version to the regular version.

      I'm not sure what is actually happening, however. It sort of looks like the 32x32 pixel @2x icon is being used but scaled down to 16x16 pixels, but not quite.

      The code in the test application is:

      int main(int argc, char *argv[])
      {
      	QApplication a(argc, argv);
      
      #if QT_VERSION >= 0x050100
      	a.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
      #endif
      
      	QDialog modalD;
      	modalD.setModal(true);
      
      	// Create buttons.
      	QPushButton* pb1 = new QPushButton(&modalD);
      	pb1->setIcon(QIcon(":/Icons/go-home.png"));
      
      	QPushButton* pb2 = new QPushButton(&modalD);
      	pb2->setIcon(QIcon(":/Icons/x-office-document.png"));
      
      	// Use a layout.
      	QHBoxLayout* hLayout = new QHBoxLayout();
      	hLayout->addWidget(pb1);
      	hLayout->addWidget(pb2);
      	modalD.setLayout(hLayout);
      
      	modalD.setWindowTitle("Modal dialog");
      	modalD.exec();
      
      	return a.exec();
      }
      
      

      Attachments

        1. good.png
          good.png
          15 kB
        2. QtCreator-icons-36vs40.png
          QtCreator-icons-36vs40.png
          121 kB
        3. test_highres_monitor.png
          test_highres_monitor.png
          25 kB
        4. test_lowres_monitor.png
          test_lowres_monitor.png
          10 kB
        5. test_nohighres_monitor.png
          test_nohighres_monitor.png
          10 kB
        6. test.zip
          5 kB
        For Gerrit Dashboard: QTBUG-38100
        # Subject Branch Project Status CR V

        Activity

          People

            sorvig Morten Sørvig
            aclight Adam Light
            Votes:
            6 Vote for this issue
            Watchers:
            11 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes