Problem with High-DPI
Unsolved
Mobile and Embedded
-
I create Qt Quick Controls Application in Qt 5.6.0 (the official release). And add support High-DPI in main.cpp:
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
If I do not write this line, the controls look normal, but the other components are small.
If I write this line, the components look good, but the controls look huge.
What to do?
Code:
#include <QApplication> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { QApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication app(argc, argv); QQmlApplicationEngine engine; engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); return app.exec(); }
main.qml
import QtQuick 2.6 import QtQuick.Controls 1.5 import QtQuick.Layouts 1.1 ApplicationWindow { visible: true width: 640 height: 480 title: qsTr("Hello World") menuBar: MenuBar { Menu { title: qsTr("File") MenuItem { text: qsTr("&Open") onTriggered: console.log("Open action triggered"); } MenuItem { text: qsTr("Exit") onTriggered: Qt.quit(); } } } Text { id: richText objectName: "richText" text: "<b>Hell2o</b> <i>World!</i><br><img src=\"2016-03-23_085632.png\"><br><img src=\"alein3.svg\">" width:300 font.family: "Times New Roman" font.pixelSize: 14 } Image { id: logo width: 90 height: 90 source: "alein3.svg" } RowLayout { anchors.centerIn: parent Button { id: button1 text: qsTr("Press Me 1") } Button { id: button2 text: qsTr("Press Me 2") } } }
Samsung Note 2014. Android 5.1.1
Jiayu S3. Android 4.4.4