Search code examples
qtqmlqtquick2qtquickcontrols2

QML's behavior depending on monitor used


I am using Qt's Example Qt Quick Controls 2 with Qt v5.7 on Ubuntu 14.04 and I observe a different display behavior depending on the monitor I display on.

I have 2 monitors: my laptop's internal monitor and an external monitor. Both are 1920 x 1080.

When I display the app on the laptop's monitor I observe this:

enter image description here

When I display the app on the external monitor I observe this:

enter image description here

And the only thing I did to go from one to the other was drag the app from one monitor to the other.

The external monitor's display is good, not the laptop's display.

I observe this behavior with all QtQuick apps and I did not modify the code of example app Qt Quick Controls 2.

Any idea of what is going on?

---------------EDIT----------------

I have used the code below and have found that my internal display (Screen.width x Screen.height) is seen by QML as 960 x 540 and my external screen seen as 1920 x 1080. My internal screen should also be 960 x 540!

Any idea why QML thinks my internal screen is 960 x 540, when it should be 1920x1080?

MouseArea
{
    anchors.fill: parent
    onClicked:
    {
        console.log("name  = "                  + Screen.name)
        console.log("width  = "                 + Screen.width)
        console.log("height  = "                + Screen.height)
        console.log("desktopAvailableWidth  = " + Screen.desktopAvailableWidth)
        console.log("desktopAvailableHeight = " + Screen.desktopAvailableHeight)
        console.log("pixelDensity   = "         + Screen.pixelDensity )
        console.log("virtualX = "               + Screen.virtualX)
        console.log("virtualY = "               + Screen.virtualY)
    }
  }

Solution

  • This is because I was using the HighDpiScaling option.

    When I got rid of line

    QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
    

    in the main.cpp loading the main.qml my problem disappeared.