Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Fixed form text size, independant from os



  • Hi,
    Is it possible to fix sizes of text/other content in qt gui app to fixed size, independant from os setting that can change overall size like 125% 150% etc?


  • Lifetime Qt Champion

    Hi,

    Do you mean going against the OS High DPI settings ?

    You can find more information about Qt's High DPI support here.



  • Yes , to stabilize the app against different os dpi settings.



  • How to:
    setAttribute(Qt::AA_Use96Dpi); to mainwindow?

    MainWin m_win; m_win.setAttribute(Qt::AA_Use96Dpi); Does not work

    QApplication app(argc,argv);
    app.setAttribute(Qt::AA_Use96Dpi);
    

    Also wont notice differene.

    Problem is that the text gets zoomed too big in labels and ui is designed by fixed cordinates for 100% dpi setting , not 125 or 150.

    How to overcome this problem?


  • Lifetime Qt Champion

    It's an application attribute not a widget attribute. You have to set it before creating your QApplication instance using QCoreApplication::setAttribute.



  • @SGaist
    Both QApplication and QWidget has the setAttribute and the options avalible.
    The setting has to be modified by the QCoreApplication::setAttribute. and cant modify it seperately for each window or QApplication instance?

    To work against high dpi settings in fixed cordinate designed app by making it small would be better than invisible text, but if possible to implement adjustable zoom for fixed cordinate app, that would allow make overall bigger/smaller would be even better solution.


  • Lifetime Qt Champion

    They both have and both have a different set of attributes. The signature of both function is different. One takes Qt::ApplicationAttribute and the other Qt::WidgetAttribute.

    What is your use of fixed coordinates ?

    The High-DPI scaling should allow your application to show and interact nicely whatever the DPI is.



  • @SGaist The ui is designed without layouts, with fixed cordinataes and most ui elements quite closely packed.


  • Lifetime Qt Champion

    Then you have to handle the High DPI stuff yourself also.


Log in to reply