Merge #16254: qt: Set AA_EnableHighDpiScaling attribute early

099e4b9ad3 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 099e4b9ad3
  jonasschnelli:
    utACK 099e4b9ad3
  fanquake:
    ACK 099e4b9ad3. 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
pull/22985/head
MarcoFalke 5 years ago
commit 44e849c35a
No known key found for this signature in database
GPG Key ID: D2EA4850E7528B25

@ -436,16 +436,17 @@ int GuiMain(int argc, char* argv[])
Q_INIT_RESOURCE(bitcoin);
Q_INIT_RESOURCE(bitcoin_locale);
BitcoinApplication app(*node, argc, argv);
// Generate high-dpi pixmaps
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#if QT_VERSION >= 0x050600
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
#ifdef Q_OS_MAC
QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
#endif
BitcoinApplication app(*node, argc, argv);
// Register meta types used for QMetaObject::invokeMethod
qRegisterMetaType< bool* >();
// Need to pass name here as CAmount is a typedef (see http://qt-project.org/doc/qt-5/qmetatype.html#qRegisterMetaType)

Loading…
Cancel
Save