gpt4 book ai didi

c++ - QML 矩形按钮高亮延迟

转载 作者:行者123 更新时间:2023-11-28 06:18:51 24 4
gpt4 key购买 nike

我有一个按钮列表,当用户按下它直到它被释放时,我想单独突出显示这些按钮。

问题在于,当您滚动列表时,您触摸的第一个按钮将突出显示,即使您触摸它一毫秒也是如此。它看起来不太好,所以我想为高亮动画添加延迟。

我认为在高亮动画发生之前稍作延迟可能会解决这个外观问题。

如何为高亮动画添加延迟?

我一直在尝试类似的东西:

Rectangle {
id: folderButton
property bool pressed: false
signal clicked

height: mainWindoww.height * 0.1
width: parent.width
color: pressed ? "lightgrey" : "white"

function release() {
autoRepeatClicks.stop()
folderButton.pressed = false
}

SequentialAnimation on pressed {
id: autoRepeatClicks
running: false

PropertyAction { target: folderButton; property: "pressed"; value: true }
ScriptAction { script: folderButton.clicked() }
PauseAnimation { duration: 1000 }

SequentialAnimation {
loops: Animation.Infinite
ScriptAction { script: folderButton.clicked() }
PauseAnimation { duration: 500 }
}
}

MouseArea {
anchors.fill: parent

onPressed: autoRepeatClicks.start()
onReleased: folderButton.release()
onCanceled: folderButton.release()
}
}

但是这段代码好像没有加任何时差

最佳答案

您可以使用 Timer为了达成这个。例如,您可以这样做:

Item {
Timer {
interval: 500;
running: true;
repeat: true
onTriggered: time.text = Date().toString()
}

Text { id: time }
}

关于c++ - QML 矩形按钮高亮延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29681606/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com