Skip to content

Commit 44e849c

Browse files
author
MarcoFalke
committed
Merge bitcoin#16254: qt: Set AA_EnableHighDpiScaling attribute early
099e4b9 Set AA_EnableHighDpiScaling attribute early (Hennadii Stepanov) Pull request description: Running `bitcoin-qt` compiled against Qt 5.12.4 causes a warning: ``` hebasto@bionic-qt:~/bitcoin$ src/qt/bitcoin-qt Attribute Qt::AA_EnableHighDpiScaling must be set before QCoreApplication is created. ``` This PR fixes this issue. From Qt docs: - [Qt::AA_EnableHighDpiScaling](https://doc.qt.io/qt-5/qt.html#ApplicationAttribute-enum): > Enables high-DPI scaling in Qt on supported platforms (see also High DPI Displays). _Supported platforms are X11, Windows and Android._ Enabling makes Qt scale the main (device independent) coordinate system according to display scale factors provided by the operating system. This corresponds to setting the `QT_AUTO_SCREEN​_SCALE_FACTOR` environment variable to 1. This attribute must be set before `QGuiApplication` is constructed. This value was added in Qt 5.6. - [QCoreApplication::setAttribute()](https://doc.qt.io/qt-5/qcoreapplication.html#setAttribute) ACKs for commit 099e4b: MarcoFalke: ACK 099e4b9 jonasschnelli: utACK 099e4b9 fanquake: ACK 099e4b9. Did some testing on `Bionic` and `Windows 10` (using VirtualBox). I couldn't see any obvious visual difference, but given Marco's screens above, this change is obviously better. I also checked that there wasn't any sort of regression on macOS. Tree-SHA512: 1965a427ee14ffb3871bac317685032406cf02d1fa2b2dc11c8b643bfe4ba09195674d149d1e41752f14c0d000446b35e142f3ce60d987ba97082fd7ee39a094
2 parents c8fee67 + 099e4b9 commit 44e849c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/qt/bitcoin.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -436,16 +436,17 @@ int GuiMain(int argc, char* argv[])
436436
Q_INIT_RESOURCE(bitcoin);
437437
Q_INIT_RESOURCE(bitcoin_locale);
438438

439-
BitcoinApplication app(*node, argc, argv);
440439
// Generate high-dpi pixmaps
441440
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
442441
#if QT_VERSION >= 0x050600
443-
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
442+
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
444443
#endif
445444
#ifdef Q_OS_MAC
446445
QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
447446
#endif
448447

448+
BitcoinApplication app(*node, argc, argv);
449+
449450
// Register meta types used for QMetaObject::invokeMethod
450451
qRegisterMetaType< bool* >();
451452
// Need to pass name here as CAmount is a typedef (see http://qt-project.org/doc/qt-5/qmetatype.html#qRegisterMetaType)

0 commit comments

Comments
 (0)