Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Icons too small and other scaling problems on high DPI monitor #40274

Closed
arencambre opened this issue Nov 25, 2020 · 11 comments
Closed

Icons too small and other scaling problems on high DPI monitor #40274

arencambre opened this issue Nov 25, 2020 · 11 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! GUI/UX Related to QGIS application GUI or User Experience

Comments

@arencambre
Copy link

arencambre commented Nov 25, 2020

Describe the bug

I have an HP EliteBook with a 4K (high DPI) monitor. When I open QGIS, the icons are tiny (Chrome browser window included in screenshot for context, and it may appear to be much larger than reality due to how Github apparently uses 72 dpi for displaying images):
image

This is a fresh install, through osgeo4w.

The Help --> About menu comes up badly messed up:
image

How to Reproduce

  1. On a computer with a 4K monitor, open QGIS. Notice how small the icons are.
  2. Help --> About

Expected behavior

QGIS and its features scale appropriately for high DPI monitors without any intervention on the part of users. I am sure some will post workarounds, and those will help others finding this bug, but workarounds are not bug fixes.

QGIS and OS versions

QGIS version
3.16.1-Hannover
QGIS code revision
b381a90
Compiled against Qt
5.11.2
Running against Qt
5.11.2
Compiled against GDAL/OGR
3.1.4
Running against GDAL/OGR
3.1.4
Compiled against GEOS
3.8.1-CAPI-1.13.3
Running against GEOS
3.8.1-CAPI-1.13.3
Compiled against SQLite
3.29.0
Running against SQLite
3.29.0
PostgreSQL Client Version
11.5
SpatiaLite Version
4.3.0
QWT Version
6.1.3
QScintilla2 Version
2.10.8
Compiled against PROJ
6.3.2
Running against PROJ
Rel. 6.3.2, May 1st, 2020
OS Version
Windows 10 (10.0)
Active python plugins
db_manager;
MetaSearch;
processing

Additional context

Laptop is running Windows 10 20H2. Fully patched. It has a quite recent, clean, bare-metal install of Windows.

Per https://issues.qgis.org/issues/17874, it appears it was believed that this was resolved.

@arencambre arencambre added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Nov 25, 2020
@gioman gioman added the GUI/UX Related to QGIS application GUI or User Experience label Nov 25, 2020
@reyemtm
Copy link

reyemtm commented Nov 25, 2020

I believe this is upstream in QT - the workaround as you mentioned at least is to create a manifest file - see this example from this post. I forget to copy my file and every time I upgrade I have to create it again. Definitely a pain and I'm not too sure on what all is absolutely necessary in the manifest file.

also this looks to be a duplicate of #20008

See my complete manifest file here - #36979

and another https://gis.stackexchange.com/questions/132491/qgis-on-uhd-screen - disregard the information regarding adjusting the compatibility settings in the properties, just the manifest file works great.

@arencambre
Copy link
Author

Thank you. That manifest workaround appears to be superseded per Dan's April 8, 2017 comment: https://danantonielli.com/adobe-app-scaling-on-high-dpi-displays-fix/#comment-16689.

@reyemtm
Copy link

reyemtm commented Nov 25, 2020

Changing the high dpi settings did not work for me. Still using the manifest file.

@DantSu
Copy link

DantSu commented Jan 5, 2022

Here a batch code to create regedit key and auto generate manifest file.
Put this code to a .bat file and execute it as administrator.

@echo off
chcp 65001
setLocal EnableDelayedExpansion

reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\SideBySide" /v PreferExternalManifest /t REG_DWORD /d 0x00000001 /f


set /p path="Please, enter full path to the .exe file:"

echo "%path%"

>"%path%.manifest" (
    echo:^<?xml version=^"1.0^" encoding=^"UTF-8^" standalone=^"yes^"?^>
    echo:
    echo:^<assembly xmlns=^"urn:schemas-microsoft-com:asm.v1^" manifestVersion=^"1.0^" xmlns:asmv3=^"urn:schemas-microsoft-com:asm.v3^"^>
    echo:
    echo:^<dependency^>
    echo:  ^<dependentAssembly^>
    echo:    ^<assemblyIdentity
    echo:      type=^"win32^"
    echo:      name=^"Microsoft.Windows.Common-Controls^"
    echo:      version=^"6.0.0.0^" processorArchitecture=^"*^"
    echo:      publicKeyToken=^"6595b64144ccf1df^"
    echo:      language=^"*^"^>
    echo:    ^</assemblyIdentity^>
    echo:  ^</dependentAssembly^>
    echo:^</dependency^>
    echo:
    echo:^<dependency^>
    echo:  ^<dependentAssembly^>
    echo:    ^<assemblyIdentity
    echo:      type=^"win32^"
    echo:      name=^"Microsoft.VC90.CRT^"
    echo:      version=^"9.0.21022.8^"
    echo:      processorArchitecture=^"amd64^"
    echo:      publicKeyToken=^"1fc8b3b9a1e18e3b^"^>
    echo:    ^</assemblyIdentity^>
    echo:  ^</dependentAssembly^>
    echo:^</dependency^>
    echo:
    echo:^<trustInfo xmlns=^"urn:schemas-microsoft-com:asm.v3^"^>
    echo:  ^<security^>
    echo:    ^<requestedPrivileges^>
    echo:      ^<requestedExecutionLevel
    echo:        level=^"asInvoker^"
    echo:        uiAccess=^"false^"/^>
    echo:    ^</requestedPrivileges^>
    echo:  ^</security^>
    echo:^</trustInfo^>
    echo:
    echo:^<asmv3:application^>
    echo:  ^<asmv3:windowsSettings xmlns=^"http://schemas.microsoft.com/SMI/2005/WindowsSettings^"^>
    echo:    ^<ms_windowsSettings:dpiAware xmlns:ms_windowsSettings=^"http://schemas.microsoft.com/SMI/2005/WindowsSettings^"^>false^</ms_windowsSettings:dpiAware^>
    echo:  ^</asmv3:windowsSettings^>
    echo:^</asmv3:application^>
    echo:
    echo:^</assembly^>
)

echo "Manifest file generated !"

pause >nul

@jbp35
Copy link
Contributor

jbp35 commented Aug 22, 2022

I am facing the same issue and I think that I have been able to track partially the origin. It appears to me that currently QGIS does not take into account the devicePixelRatio as it can be seen in this comparison of QGIS console output and the standalone DprGadget provided by QT:

Screenshot 2022-08-20 090325

The UI scaling issue can be fixed by adding the following lines of code to https://github.com/qgis/QGIS/blob/master/src/app/main.cpp after line 918

// Set up for high DPI displays
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);

Note: @nyalldawson this can be of interest as I think that QT6 set these attributes by default.

Alternatively, it is also possible to run qgis from a batch file with following commands to test:

set QT_ENABLE_HIGHDPI_SCALING=1 
set QT_SCALE_FACTOR_ROUNDING_POLICY=PassThrough
C:\OSGeo4W\bin\qgis-bin.exe

However, it is not possible to set UseHighDpiPixmaps from command line so the icons will look blurry.

After doing this, UI looks great on my device. However, there seems to be an issue with the scale of the map on the high DPI screen which is 2X too big. I have not been able to figure out where this comes from, but it looks like QgsMapSettings currently use a default devicePixelRatio of 1 which is never been updated.

Before:
before

After:
after

@GvdDool
Copy link

GvdDool commented Apr 8, 2023

Apologies for stepping in late, but I am facing similar problems on my Windows 13'' laptop with full HD1080.

I don't know enough about fixing/editing the code base, so I wouldn't know where to change:
// Set up for high DPI displays
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);

and test if this solved my problem of having a status bar not behaving as expected (related conversation on: https://gis.stackexchange.com/questions/457210/qgis-gui-layout-and-screen-scaling-in-windows?noredirect=1#comment746623_457210

I hope someone can direct me to some resources to fix the GUI. Thanks.

Ps. I could start a new topic, but I think my problem(s) are related to this issue.

@jbp35
Copy link
Contributor

jbp35 commented Apr 11, 2023

On windows, you just have to copy and paste the following content in a .txt file (changing the path to qgis executable if necessary):

set QT_ENABLE_HIGHDPI_SCALING=1 
set QT_SCALE_FACTOR_ROUNDING_POLICY=PassThrough
C:\OSGeo4W\bin\qgis-bin.exe

After saving, change the extension from .txt to .bat and execute run the file.

@GvdDool
Copy link

GvdDool commented Apr 11, 2023

Thanks jbp35,
From your earlier comment:

However, it is not possible to set UseHighDpiPixmaps from command line so the icons will look blurry.

Is there a workaround for this, or should I try and see how blurry the icons are after setting the parameters?

@jbp35
Copy link
Contributor

jbp35 commented Apr 12, 2023

Thanks jbp35, From your earlier comment:

However, it is not possible to set UseHighDpiPixmaps from command line so the icons will look blurry.

Is there a workaround for this, or should I try and see how blurry the icons are after setting the parameters?

You can give it a try, anyway these settings will only apply when you launch QGIS using the .bat file.

@GvdDool
Copy link

GvdDool commented Apr 12, 2023

Thanks, jbp35, but I think I will try to downgrade to my previous version first, and I hope that by doing so I can normally work again before using scripts to workaround a problem introduced by upgrading to the latest version.

@nyalldawson
Copy link
Collaborator

Should be all fixed in QGIS 3.32 -- please open new tickets for any specific individual hidpi issues remaining after this release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! GUI/UX Related to QGIS application GUI or User Experience
Projects
None yet
Development

No branches or pull requests

7 participants