PDA

View Full Version : QML Window unable to set geometry when moving across screens



mont3z
4th February 2019, 22:30
Hi all,

I'm having some problem with my application where when I drag it from a HD monitor to a 4k monitor with 125% dpi scaling my application print error like:


QWindowsWindow::setGeometry: Unable to set geometry 640x480+3210+774 on QQuickApplicationWindow_QML_0/''. Resulting geometry: 1280x960+3210+774 (frame: 0, 0, 0, 0, custom margin: 0, 0, 0, 0, minimum size: 0x0, maximum size: 16777215x16777215).


Sometimes the window will resize to very large or very small sizes just by dragging it from one monitor to the other (OS Windows 10).

EDIT: I forgot to say but I have on my application:


QGuiApplication::setAttribute(Qt::AA_EnableHighDpi Scaling);

Dpi scaling works fine until suddenly the problem happens after moving the window a couple of times back and forth.

Please see below a snippet of my code:



import QtQuick 2.10
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
import QtQuick.Controls.Styles 1.4
import QtWebEngine 1.8

ApplicationWindow {
id: mainWindow
visible: true
width: 640
height: 480

flags: Qt.Window | Qt.FramelessWindowHint // Frameless window

StackView {
id: stack
anchors.fill: parent

Rectangle {
id: menubar
width: parent.width
height: 20
color: "black"

RowLayout {
anchors.fill: parent

Item { Layout.fillWidth: true }
Button {
id: minimize_btn
Layout.preferredWidth: 20
Layout.preferredHeight: 20

background:
Rectangle
{
antialiasing: true
color: "transparent"
}

Image {
anchors.leftMargin: 3
anchors.rightMargin: 3
anchors.topMargin: 8
anchors.bottomMargin: 8
anchors.fill: parent
source: "qrc:/titleBarWin/minimize_button.png"
}
}
Button {
id: maximize_btn
Layout.preferredWidth: 20
Layout.preferredHeight: 20

background:
Rectangle
{
antialiasing: true
color: "transparent"
}

Image {
anchors.leftMargin: 5
anchors.rightMargin: 5
anchors.topMargin: 5
anchors.bottomMargin: 5
anchors.fill: parent
source: "qrc:/titleBarWin/maximize_button.png"
}
}
Button {
id: close_btn
Layout.preferredWidth: 20
Layout.preferredHeight: 20

background:
Rectangle
{
antialiasing: true
color: "transparent"
}

Image {
anchors.leftMargin: 5
anchors.rightMargin: 5
anchors.topMargin: 5
anchors.bottomMargin: 5
anchors.fill: parent
source: "qrc:/titleBarWin/close_button.png"
}
}
}
}

WebEngineView {
id: webEngine
anchors {
top: menubar.bottom
left: menubar.left
right: menubar.right
}

height: parent.height

url: "https://www.qt.io"
}
}
// define mouse areas to resize/move window
}