我正在使用Qt 5.2 beta,Qt Quick 2.1。
我遇到了一个关于Flickable
组件的问题。
这是一个最小工作示例:
import QtQuick 2.1
import QtQuick.Controls 1.0
ApplicationWindow {
width: 300
height: 200
Rectangle {
anchors.fill: parent
color: "green"
Flickable {
id: flickArea
anchors {fill: parent; margins: 10; }
contentWidth: rect.width;
contentHeight: rect.height
Rectangle {
id: rect
x: 0; y: 0;
width: 200; height: 300;
color: "lightgrey"
Rectangle {
anchors { fill: parent; margins: 10; }
color: "red"
}
}
}
}
Button {
anchors.bottom: parent.bottom;
anchors.horizontalCenter: parent.horizontalCenter;
text: "Scale flickArea"
onClicked: { flickArea.scale += 0.2; }
}
}
当我进行缩放时,我希望所有子元素仍然保持原来的可见性,并且内部区域变得更大。
但是,相反,子元素会移出可滚动内容。
有人能提出一种正常的方法来避免这个问题,而不需要手动重新计算所有偏移量吗?