Important: Please read the Qt Code of Conduct -

QtQuick app Screen Affinity?

  • We have an app that has had a lot of developers work on it so I am not sure where to look. It is a QtQuick app. When we launch this app on a computer with multiple screens it always starts in the main desktop screen, screen 1. When trying to move to a second screen (screen 2) it snaps back to the center of screen 1. I tested a regular QtQuick app generated by Qt Creator and it does not do this.

    I tested this behavior on Windows 10 Pro and on Ubuntu 18.04 with our app. It snaps back on both OSes. So I think this is not related to a particular OS configuration.

  • Okay, after careful scrutiny I found this gem:

    x: (Screen.width - main_window.width) / 2
    y: (Screen.height - main_window.height) / 2

    So I put this code in a Component.onCompleted function instead:

    main_window.x = (Screen.width - main_window.width) / 2
    main_window.y = (Screen.height - main_window.height) / 2

    The issue went away in Ubuntu. So I will be testing Windows next.

Log in to reply