Changing DPI scaling size of display make Qt application's font size get rendered bigger

前端 未结 5 1175
滥情空心
滥情空心 2020-12-02 10:20

I have created some GUI application using Qt. My GUI application contains controls like push button and radio button. When I run the application, buttons and fonts inside bu

5条回答
  •  隐瞒了意图╮
    2020-12-02 11:07

    High DPI support is enabled from Qt 5.6 onward.

    Setting QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling) in your application source code allows automatic high-DPI scaling.

    NOTICE: To use the attribute method, you must set the attribute before you create your QApplication object:

    #include 
    
    int main(int argc, char *argv[])
    {
        QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    
        QApplication app(argc, argv);   
        return app.exec();
    }
    

提交回复
热议问题