My application has a main window with a button, and when I click the button, I use createComponentto create a subclass Window {}and show it (only in QML). I am running the application on my macbook with a different monitor connected.
If I am not trying to set properties .xor .ymy new window, then it appears on top of my main window, regardless of whether the main window is on my macbook screen or on a connected monitor (i.e. a new window is always displayed on the same screen as and the main window). However, if I set properties .xor a .ynew window (for any value whatsoever), then the new window always appears on the macbook screen, regardless of which screen I have the main window on.
How can I control which available screen is displayed in my new window? And related, how can I precisely control the positioning of a new window on the screen (for example, how can I open a new window in the lower right corner)?
Edit: base code. RemoteWindow.qml
Window {
id: myWindow
flags: Qt.Window | Qt.WindowTitleHint | Qt.WindowStaysOnTopHint
| Qt.WindowCloseButtonHint
modality: Qt.NonModal
height: 500
width: 350
// window contents, doesn't matter
}
(remoteControl - , ):
function showRemoteWindow() {
remoteControl.x = Screen.width - remoteControl.width
remoteControl.y = Screen.height - remoteControl.height
remoteControl.show()
}
, onClicked: :
if (remoteControl) {
showRemoteWindow()
} else {
var component = Qt.createComponent("RemoteWindow.qml")
if (component.status === Component.Ready) {
remoteControl = component.createObject(parent)
showRemoteWindow()
}
}
.x .y showRemoteWindow, RemoteWindow , ( macbook, ). ( x y ), RemoteWindow macbook, , .