【发布时间】:2022-01-11 15:49:17
【问题描述】:
我的目的是在调整大小时将窗口粘贴到屏幕的右对齐。
在窗口宽度和 x(绑定到宽度)的动画(或更改显式)期间,ApplicationWindow 向左弹跳(显式更改闪烁)。
我已经在寻找解决方案,但没有什么对我有用。 添加属性:
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
帮了很多忙,但窗口仍然左右弹跳。
main.qml:
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import QtQuick.Controls.Material 2.15
ApplicationWindow {
id: root
height: 300
width: 300
visible: true
flags: Qt.FramelessWindowHint
x: Screen.width - width
Material.theme: Material.Dark
NumberAnimation on width {
id: animation
easing.type: Easing.InOutQuad
}
property var lowerSize: true
Rectangle {
anchors.fill: parent
Button {
anchors.centerIn: parent
enabled: !animation.running
text: lowerSize ? 'Size up' : 'Size down'
onClicked: {
animation.from = lowerSize ? 300 : 600
animation.to = lowerSize ? 600 : 300
animation.start()
lowerSize = !lowerSize
}
}
}
}
我已经在 github qml-flickering-example 上制作了用于重现问题的示例代码。
【问题讨论】: