Skip to content

Commit 3ca03ab

Browse files
author
johan.andruejol
committed
BUG: Fix high DPI display on windows with multiple screens
The issue arises when displaying Slicer on multiple high dpi screens. A transparent bar is displayed below the toolbar and shifts the whole rendering. This comes from the Qt windows display plugin (QPA layer) that sets the windows dpi awarness to PROCESS_PER_MONITOR_DPI_AWARE by default. Although it is the appropriate value, Qt doesn't handle it properly. Unfortunately, there is no API to call to change the ProcessDPIAwarness value. We can however directly call the windows method SetProcessDPIAware() that will superseed the Qt call and set the ProcessDPIAwarness to PROCESS_SYSTEM_DPI_AWARE instead which solves the issue. For reference: http://doc.qt.io/qt-5/qpa.html https://msdn.microsoft.com/en-us/library/windows/desktop/dn280512(v=vs.85).aspx git-svn-id: http://svn.slicer.org/Slicer4/trunk@26936 3bd1e089-480b-0410-8dfb-8563597acbee
1 parent 6935859 commit 3ca03ab

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Applications/SlicerApp/Main.cxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,14 @@ int SlicerAppMain(int argc, char* argv[])
118118
#endif
119119

120120
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
121+
#ifdef _WIN32
122+
// Qt windows defaults to the PROCESS_PER_MONITOR_DPI_AWARE for DPI display
123+
// on windows. Unfortunately, this doesn't work well on multi-screens setups.
124+
// By calling SetProcessDPIAware(), we force the value to
125+
// PROCESS_SYSTEM_DPI_AWARE instead which fixes those issues.
126+
SetProcessDPIAware();
127+
#endif
128+
121129
// Enable automatic scaling based on the pixel density of the monitor
122130
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
123131
#endif

0 commit comments

Comments
 (0)