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

[Qt Widgets] Widget far too large, fonts OK ?



  • Hi there,

    We are currently reinstalling our apps on a new Real-Time Linux-based machine, based on CentOS 8.3, with Qt5.9.9 (built from sources). We are running into a strange but critical bug tied to Qt Widget.

    With one (and only one) of our app :

    • all the widgets and windows are very big on screen (like 3 to 4 times bigger than they should be). Cf the screen capture below
    • still, the fonts are displayed with the correct size.

    capture_G4.png

    Still, the Qt installation is OK : examples run fine ; and the widget size problem does not occur with any of our other apps (compiled and linked with the exact same options and libraries, and run with the same dynamic libraries).
    Finally, the failing app (same exact source code) compiles and runs OK on Ubuntu, Mac and Windows with also Qt5.9.9.

    Hence, the problem only occurs on our "special" real time Linux, and only with this specific app.

    I suspect this is a weird bug in our code, that is only revealed on this specific OS/Qt distribution. It may be due to a bad QPainter::scale(...) ; save() or restore()... Or something else approaching... I may be totally wrong though.

    We have browsed quite extensively our code and compilation options, with no success so far.

    Perhaps someone may have a hint for us ? Eg where we may give another look in our code... That would be a-we-some :)

    Thank you very much !
    Nicolas


  • Lifetime Qt Champion

    Hi
    That is new. :)

    I would check:

    • the use of stylesheets (if any)

    • try run app with scaling disabled
      https://doc.qt.io/qt-5/highdpi.html

    • add a new form to the project and place one widget on it
      and see if that suffer the same even if "fresh"



  • Hi all, hi mrjj,

    thanks for your answers and help.

    In fact, the bug was related an application-wide high dpi scaling setting.

    Our main() called

    QCoreApplication::setAttribute( Qt::AA_EnableHighDpiScaling, true)
    

    Commenting this line solves the issue on our Linux.

    This call is OK on almost all our Linux machines (with and without high DPI screens).
    I am wondering why it conversely triggers a resolution issue on our cent-os-based real time OS (without high DPI screen) !

    => In case you want me to investigate in this, how should we proceed ? SHould we look into some system configuration files ?

    Finally, I guess I have to update the way our app manages high/standard DPI screens issues, in our multiplatform context.
    We used to enable Qt::AA_EnableHighDpiScaling with Qt5.6 quite a long time ago.

    => But in fact, today, we should NOT enable Qt::AA_EnableHighDpiScaling, should we ?

    Thanks again.
    Issue solved !
    Nicolas


  • Lifetime Qt Champion

    Hi
    Ok that was lucky. :)

    I am wondering why it conversely triggers a resolution issue on our cent-os-based real time OS (without high DPI screen) !

    Me too as I not seen it does such strange stuff across operating systems.

    => In case you want me to investigate in this, how should we proceed ? SHould we look into some system configuration files ?

    Well I would start with logging the values from
    https://doc.qt.io/qt-5/qscreen.html
    looking values like
    https://doc.qt.io/qt-5/qscreen.html#devicePixelRatio-prop
    as docs says
    "The Qt::AA_EnableHighDpiScaling application attribute, introduced in Qt 5.6, enables automatic scaling based on the monitor's pixel density."
    So i guess it somehow got some odd values on this linux Os.
    So i would be lazy and reuse some code like
    https://www.ics.com/blog/whats-new-qt-5-qscreen-class
    and then compare the values between the issues Os and a working one.

    Finally, I guess I have to update the way our app manages high/standard DPI screens issues, in our multiplatform context.
    We used to enable Qt::AA_EnableHighDpiScaling with Qt5.6 quite a long time ago.
    => But in fact, today, we should NOT enable Qt::AA_EnableHighDpiScaling, should we ?

    Well normally it's quite ok to leave it ON as the scaling normally only kicks in when it is in fact a hires screen.
    You should check what value QT_SCALE_FACTOR gets as that has a huge effect of the size of the widgets.
    docs states: "Note: Non-integer scale factors may cause significant scaling/painting artifacts."
    so i do wonder if that is our first real life example :)

    you are welcome :)


Log in to reply