Quantcast
Channel: Active questions tagged qtquick2 - Stack Overflow
Viewing all articles
Browse latest Browse all 137

window flickering when resizing QML

$
0
0

The application window flickers when I change its size

enter image description here

part of the code responsible for resizing

        MouseArea { // изменениеразмера top        width: parent.width        height: 2        cursorShape: Qt.SizeVerCursor        onPressed: {            mainWindow.previousY = mouseY        }        onPositionChanged: {            mainWindow.setHeight(mainWindow.height - (mouseY - mainWindow.previousY))        }    }

full code

import QtQuick 2.15import QtQuick.Controls 2.15import "../resources/"ApplicationWindow {    id: mainWindow    visible: true    width: 640    height: 480    flags: Qt.FramelessWindowHint // Отключениестандартногообрамленияокна    property int previousX // переменнаяхранящая X зажатогокурсора    property int previousY // переменнаяхранящая Y зажатогокурсора    readonly property real toolBarHeight: toolBar.height // переменнаяхранящаяразмер toolBar    readonly property real maxWidthSize: Screen.desktopAvailableWidth // переменнаяхранящаямаксимальнуюширинаокна    readonly property real maxHeightSize: Screen.desktopAvailableHeight // переменнаяхранящаямаксимальнуюдлинуокна    property real lastWidthSize: 640 // переменнаяхранящаяпоследнююнемаксимальнуюширинаокна    property real lastHeightSize: 480 // переменнаяхранящаяпоследнююнемаксимальнуюдлинуокна    property real lastWindowX: mainWindow.x // переменнаяхранящаяпоследееположениеокнапо X    property real lastWindowY: mainWindow.y // переменнаяхранящаяпоследнееположениеокнапо Y    Rectangle {        id: toolBar        width: parent.width        height: 34        color: Colors.toolBarColor        MouseArea { // перемещениеокна            anchors.fill: parent            onPressed: {                mainWindow.previousX = mouseX                mainWindow.previousY = mouseY            }            onDoubleClicked: {                if(mainWindow.maxWidthSize == mainWindow.width && mainWindow.maxHeightSize == mainWindow.height)                {                    mainWindow.setWidth(mainWindow.lastWidthSize)                    mainWindow.setHeight(mainWindow.lastHeightSize)                    mainWindow.setX(mainWindow.lastWindowX)                    mainWindow.setY(mainWindow.lastWindowY)                }                else                {                    mainWindow.setWidth(mainWindow.maxWidthSize)                    mainWindow.setHeight(mainWindow.maxHeightSize)                }            }            onPositionChanged: {                mainWindow.setX(mainWindow.x + (mouseX - mainWindow.previousX))                mainWindow.setY(mainWindow.y + (mouseY - mainWindow.previousY))                mainWindow.lastWindowX = mainWindow.x                mainWindow.lastWindowY = mainWindow.y            }        }        MouseArea { // изменениеразмера top            width: parent.width            height: 2            cursorShape: Qt.SizeVerCursor            onPressed: {                mainWindow.previousY = mouseY            }            onPositionChanged: {                mainWindow.setHeight(mainWindow.height - (mouseY - mainWindow.previousY))            }        }    }}

when I change the measurement by double-clicking (upper MouseArea) I don’t notice such problems, I think the problem is that the application is redrawn all the time when the size is changed, can this be fixed somehow?

OC Ubuntu 24.04.1 LTS


Viewing all articles
Browse latest Browse all 137

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>