我想爲Flickable
創建某種形式的視覺「反彈邊緣」效果。但是這個邊緣是一個很堅硬的邊緣,就像一堵牆一樣,所以內容不能隨時被拖拽或滑過。Qt QML。如何讓Flickable的內容反彈而不超過它?
下面是一些代碼,我設置了StopAtBounds
,但後來我不能使用反彈轉換。
import QtQuick 2.7
import QtQuick.Controls 1.4
ApplicationWindow
{
visible: true
width: 800
height: 800
Flickable
{
anchors.fill: parent
contentWidth: bob.width
contentHeight: bob.height
rightMargin: 200
leftMargin: 200
topMargin: 200
bottomMargin: 200
// prevents bob from going outside of bounds,
// but now cant use `rebound` transition.
// so how to apply `Easing.OutBounce`
boundsBehavior: Flickable.StopAtBounds
Rectangle
{
id: bob
width: 600
height: 600
color: "red"
}
}
}
您可以輕彈紅場和它擊中牆壁,但它不反彈。
有什麼建議嗎?
我不認爲'Flickable'是針對這種類型的行爲製作的,也不支持自定義行爲。 –
還沒有,至少:https://bugreports.qt.io/browse/QTBUG-38515 – GrecKo