Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Resolution Inconsistency



  • Hi everybody,
    I have an embedded system that has Debian based linaro and LXQt desktop manager has resolution 1024x768. I have created a qml based program that has 1024x768 resolution. But it shows itself bigger.
    0_1552290151612_resolution.jpeg

    and my app
    0_1552290173189_program.jpeg

    My main.qml

    Window {
        id: root
        visible:true
        width: 1024
        height: 768
        title: qsTr("autovip") + mytrans.emptyString
        modality: Qt.ApplicationModal
        flags: Qt.Window | Qt.FramelessWindowHint
        color: "black"
        Intro{
            x:0
            y:0
            z:1334
            width:1024
            height:768
            opacity: 1
        }
    
        Image {
            x:0
            y:0
            source: "qrc:/design/general/background.svg"
            width:parent.width
            height:parent.height
            Body{
                id: bodyPart
                x:0
                y:0
            }
            BottomMenu
            {
                id: iBottomMenu
                x:0
                y:690
            }
        }
        CommandInfo{
            id:info
            z:332
            width:1024
            height:768
        }
        Item{
           id:start
           width:1024
           height:768
           opacity: 0.7
           Rectangle{
               x:0
               y:0
               width:1024
               height:768
               color:"black"
               z:333
               MouseArea{
                  anchors.fill: parent
               }
           }
        }
           Rectangle{
               id:startBtn
               anchors.centerIn: start;
               radius: 50
               width: 200
               height:200
               color:"white"
               z:334
               opacity: 1
               property int systemstate: serial_mng.systemstate
               onSystemstateChanged: {
                   switch(systemstate)
                   {
                   case -1:
                   case 0:
                            start.visible=true;
                            startBtn.visible=true;
                       break;
                   case 1:
                            start.visible=false;
                            startBtn.visible=false;
                       break;
                   }
               }
               Image{
                   anchors.centerIn: parent
                   source:"qrc:/design/general/on-button.svg"
                   sourceSize.width: 150
                   sourceSize.height: 150
                  z:334
                   MouseArea{
                       anchors.fill: parent
                       onClicked: {
                           GSystem.systemOnOff();
                       }
                   }
               }
               MouseArea{
                   anchors.fill: parent
               }
    
           }
       MouseArea {
        anchors.fill: parent
        enabled: false
        //cursorShape: Qt.BlankCursor
      }
        Component.onCompleted: {
            GSystem.phistory = ["Home"];
            GSystem.state = "Home"
            GSystem.setInfo(info);
            console.log(SM.value("main/lang"));
            console.log("Serial Con : "+serial_mng.isConnected());
    
        }
    }
    
    

    What is the problem?


  • Moderators

    Don't use hardcoded dimensions and positioning if you can. It's a can of worms. Better use anchors or layouts, then your UI will always adjust itself to available screen size.

    Regarding the code - not sure what I'm seeing. So your window is wider than you want it to be, right? Or it is not positioned in top-left corner?



  • @sierdzio said in Resolution Inconsistency:

    So your window is wider than you want it to be, right?

    Yes, it is wider than I want. I have also tested it with a qwidget applicaiton given preferred size 1024x767 and it worked as expected.

    Also this program is working well without lxqt desktop manager in another embedded hardware.


  • Moderators

    Hm, perhaps some DPI scaling issue, then. Check the options in HiDPI support page, maybe something will help.



  • @sierdzio
    I had this line below and I removed it and now program works as expected.

        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    

    Thanks sierdzio


Log in to reply