Retina and setWindowIcon() in Qt 5.1.0



  • I'm very happy now Retina support seems much better in Qt 5.1.0 release.

    I seem to have a problem with setWindowIcon() and the pixmap used in a QMessageBox::about().

    a) If I use only a 2x pixmap for the icon, then the displayed image is high res but cropped.
    b) If I set a 1x pixmap and a 2x pixmap then the 1x pixmap is used, that looks bad.

    Is there a solution to this ?
    Is it because I'm emulating a retina display ?



  • Hi, are you talking specifically about Mac or in general about high-res displays? I might give it a try when I have time.



  • Yes, I'm testing on a Mac.



  • I think I'm running into the same problem. For some reason the title bar icon on my application looks blurry. I'm building up an icon using 16x16, 32x32, 64x64 and 128x128 images. I tried adding a 2x versions of the 16x16, 32x32 and 64x64, 128x128 and 256x256. Unfortunately this seems to have no effect. I'm doing this all manually like so:

    @QList<int> resolutions;
    resolutions << 16 << 32 << 64 << 128 << 256;

    QIcon icon;
    
    for(int r=0; r<resolutions.count(); r++)
    {
      int     resolution = resolutions[r];
      QString filename   = iconDir.arg(resolution);
    
      QPixmap normal(filename);
      icon.addPixmap(normal);
    
      QString retinaFilename = filename;
      retinaFilename.insert(retinaFilename.length() - 4, "@2x");
      if(dir.exists(retinaFilename))
      {
        normal = QPixmap(retinaFilename);
        normal.setDevicePixelRatio(2);
        icon.addPixmap(normal); 
     }
    

    }

    setWindowIcon( icon );
    @
    This basic approach (using @2x suffices and setting the device pixel ratio to 2) has worked fine for using images for labels and rendering images directly to custom buttons, but seems to not work when building icons for use in the title bar...

    Update: Never mind, I realized i need to set QApplication::AA_UseHighDpiPixmaps.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.