Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Retina and setWindowIcon() in Qt 5.1.0
QtWS25 Last Chance

Retina and setWindowIcon() in Qt 5.1.0

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.5k Views
  • 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 Offline
    K Offline
    kegon
    wrote on last edited by
    #1

    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
    0
    • S Offline
      S Offline
      Skh1002
      wrote on last edited by
      #2

      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
      0
      • K Offline
        K Offline
        kegon
        wrote on last edited by
        #3

        Yes, I'm testing on a Mac.

        1 Reply Last reply
        0
        • W Offline
          W Offline
          wstokes
          wrote on last edited by
          #4

          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
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved