Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Problem with High-DPI
QtWS25 Last Chance

Problem with High-DPI

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
high dpiandroidaaenablehighdp
1 Posts 1 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    Harrix
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved