COVESA / dlt-viewer

Diagnostic Log and Trace viewing program
Other
438 stars 243 forks source link

[Windows] High DPI Displays and scale factor != 100% #205

Open gobater opened 3 years ago

gobater commented 3 years ago

In the last releases Qt has been introducing support for high DPI Displays (https://doc.qt.io/qt-5/highdpi.html). According to the documentation, High DPI support is enabled from Qt 5.6 onward

In a Windows PC, in high DPI displays when using scaling, DLT-viewer looks weird. The Qt Widgets seem to be scaled twice: once by the system, and another by Qt. The screenshot below compares DLT-Viewer 2.16 (Qt 5.5) with DLT-Viewer 2.21 (Qt 5.14) and windows explorer in a high DPI display (4k resolution, 27") with 150% scaling (no photoshop: the three windows are rendered in the same screen at the same time).

Compare the text size (menus) and toolbar icons in the three windows. Note also some rendering artifacts in old DLT-Viewer image

The problems become worse in combination with multiple displays and different scale factors.

This might seem a Qt issue, and not related to DLT-Viewer. However, making the application High DPI and scaling aware could improve rendering (similar experience to Ms. Windows) in all kind of combinations (multiple monitors and different scale factors).

According to the Qt documentation about HighDpiScaleFactorRoundingPolicy (https://doc.qt.io/qt-5/qt.html#HighDpiScaleFactorRoundingPolicy-enum) and the results observed rounding seems to apply for non integer scaling factors (like 150%) making Qt to scale (again) the widgets. Setting the environment variable QT_SCALE_FACTOR_ROUNDING_POLICY to "Passthrough" before starting Dlt-Viewer makes the DLT-Viewer to look nice again in all monitors (also with different scaling).

Comparison of Dlt-Viewer in a high DPI display (4k resolution, 27") with 150% scaling and Passthrough rendering policy. image

It seems that MS Windows provides an API (SetProcessDPIAware()) which shall/could be used in this cases... https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setprocessdpiaware

In the following links several solutions are presented, using the previous MS Windows APIs:

Additional web resources:

alexmucde commented 2 years ago

I see same issues also when switching between different monitors with different resolutions. Some Windows applications automatically detects this and changes the resolution. Also a zoom feature would be nice, especially useful during presentations. Any contributers here to work on this?

alexmucde commented 8 months ago

@gobater Still an issue? Very old ticket.

gobater commented 8 months ago

@alexmucde , yes still present on 2.25.0 looks awful on my 150% scaled monitor.

Setting the environment variable QT_SCALE_FACTOR_ROUNDING_POLICY to the right value (Passthrough) makes dlt-viewer to look how it shall.