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. High DPI ("Retina") support in Qt 5.5 - handling multiple displays of different DPIs
Forum Update on Monday, May 27th 2025

High DPI ("Retina") support in Qt 5.5 - handling multiple displays of different DPIs

Scheduled Pinned Locked Moved General and Desktop
retinahigh dpi
1 Posts 1 Posters 874 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.
  • W Offline
    W Offline
    Will
    wrote on last edited by Will
    #1

    I'm in the process of updating my app to support x2 resolution bitmaps for all of the app's graphics on Mac OS 10.10 with Qt 5.5. I've found that on systems with both a retina display and a non-retina display, the 2x graphics look pretty horrible on the non-retina display as they are scaled down.

    So instead of just setting which version of the image to use when a window is created based on if any display was high DPI, I'm trying to do it dynamically based on which screen the window is on.

    Before I could set the image to use in a QLabel from within my dialog's .ui file. However now I need to switch the image based on the display it's on, so I'm hard-coding all of the image names which isn't every elegant - especially when there are many different images in the dialog. For example I have:

    my_dialog::::update_retina_icons()
    {
        static int previous_devicePixelRatio;
        int new_devicePixelRatio=devicePixelRatio();
        if (previous_devicePixelRatio!=new_devicePixelRatio)
        {
        previous_devicePixelRatio=new_devicePixelRatio;
        if (new_devicePixelRatio > 1.0)
            label->setPixmap(QPixmap(":/images/Resources/abc@2x.png")); 
        else
            label->setPixmap(QPixmap(":/images/Resources/abc.png")); 
        }
    }
    

    Does anyone have a better suggestion on how to do this so I'm not basically duplicating setting QLabel graphics from within my code from those that were set from the original .ui file?

    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