Qt World Summit: Submit your Presentation

Wrong Device Pixel Ratio (DPR) when using multiple screens with different DPR

  • Hi,

    I have a retina mac book pro connected with a bigger screen:
    Screen1: LCD (retina, devicePixelRatio=2) 1280x800 (in device points)
    Screen2: LED Cinema Display (non retina, devicePixelRatio=1) 1920x1200

    The problem is this:
    If my QtQuick main window starts in Screen2, it detects the wrong screen (Screen1). Therefore, if I drag the window to Screen1, no signal is raised that the screen is changed. This prevents me to update my OpenGL renderer with the correct devicePixelRatio.

    I have written a simple test application in QML to show this:

    import QtQuick 2.4
    import QtQuick.Controls 1.3
    import QtQuick.Window 2.2
    ApplicationWindow {
        id: appWin
        title: qsTr("Hello World")
        width: 440
        height: 320
        visible: true
        Screen.onDevicePixelRatioChanged: {
            console.log("dpr changed");
            dprSignalId.text = "dpr changed at seconds: " + new Date().getSeconds();
               id: screenTextId
               text: Screen.name + " " + Screen.devicePixelRatio + " " + Screen.width + "x" + Screen.height
               id: dprSignalId

Log in to reply