Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Retina and setWindowIcon() in Qt 5.1.0

    General and Desktop
    3
    4
    2374
    Loading More Posts
    • 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.
    • K
      kegon last edited by

      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 ?

      1 Reply Last reply Reply Quote 0
      • S
        Skh1002 last edited by

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

        1 Reply Last reply Reply Quote 0
        • K
          kegon last edited by

          Yes, I'm testing on a Mac.

          1 Reply Last reply Reply Quote 0
          • W
            wstokes last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • First post
              Last post