How to detect when the user has resized the window?
-
Hi everyone, I'm writing an app where the main window is usually resized based on the size of the content currently shown. But if the user has resized the window, then the window enters a "fixed resize" mode, where the app should not resize itself automatically.
Is it possible to detect when the user has resized a window?
This is the code that I've tried so far:
import QtQuick 2.0 import QtQuick.Controls 2.15 as QQC2 QQC2.ApplicationWindow { id: root visible: true width: 300 height: 240 color: "steelblue" property bool resizedByApp: false property bool fixedSizeMode: false onFixedSizeModeChanged: console.log("fixedSizeModeChanged", fixedSizeMode) onWidthChanged: { if (!resizedByApp) { fixedSizeMode = true } } onHeightChanged: { if (!resizedByApp) { fixedSizeMode = true } } function resizeApp(newWidth, newHeight) { if (fixedSizeMode) { return } root.resizedByApp = true width = newWidth height = newHeight root.resizedByApp = false } QQC2.Button { text: "Resize me" onClicked: resizeApp(500, 500) } }but when I click on the button, the window is resized before
resizedByAppis set to true.(btw I'm using Qt 5.15.9)