High-DPI Support in Qt Labs Controls

Qt Labs Controls support Qt's cross-platform high-DPI scaling introduced in Qt 5.6. The feature is opt-in, and can be enabled by setting the Qt::AA_EnableHighDpiScaling application attribute in C++ before QGuiApplication is constructed:

#include <QGuiApplication>
#include <QQmlApplicationEngine>

int main(int argc, char *argv[])
{
    QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // <--
    QGuiApplication app(argc, argv);
    QQmlApplicationEngine engine;
    engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
    return app.exec();
}

Alternatively, an environment variable QT_AUTO_SCREEN_SCALE_FACTOR=1 can be set to enable automatic high-DPI scaling.

Warning: Qt Quick Controls 1.x are not compatible with Qt's automatic high-DPI scaling. There is currently no available solution for high-DPI support in applications wishing to mix Qt Quick Controls and Qt Labs Controls.

© 2017 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.