Automatic rescaling of an application on high-dpi Windows platform?

后端 未结 5 965
轮回少年
轮回少年 2020-11-28 10:48

I\'m writing a Qt application that needs to run on high-dpi Windows (192dpi instead of 96dpi).

Unfortunately the Qt framework does not have support for high-dpi yet

5条回答
  •  北海茫月
    2020-11-28 11:03

    I' am using Qt 4.8.7. This is my code.

    static float dpiX = (float)0;
    inline int autoDpiSize(int inSize)
    {
        if (dpiX == (float)0)
        {
            HDC screen = GetDC(0);
            dpiX = static_cast(GetDeviceCaps(screen, LOGPIXELSX)) / 96.0;
            ReleaseDC(0, screen);
        }
        return dpiX * inSize;
    }
    someWidget->setFixedHeight(autoDpiSize(30));
    

提交回复
热议问题