【发布时间】:2020-09-28 12:50:20
【问题描述】:
通过在 QML 中编辑手动文本字段,调用一系列信号:textEdited(),然后是 textChanged()。我有两个处理程序,一个用于 onTextEdited,另一个用于 onTextChanged。
如何在 TextEdited() 处理程序中阻止 textChanged() 调用? 如何中断信号调用序列?
TextField {
id: _field
background: _textBackground
onTextChanged: {
_textBackground.border.color = "#FFBDBDBD"
_textBackground.border.width = 1
}
onTextEdited: {
_textBackground.border.color = "#FFE57439"
_textBackground.border.width = 2
}
}
Rectangle {
id: _textBackground
border {
width: 1
color: "#FFBDBDBD"
}
}
【问题讨论】:
-
你想用这段代码做什么?我不明白实际目标是什么。
-
@GrecKo
TextField字段中的代码可以通过编程和手动方式更改。当以编程方式更改时,触发TextChanged()信号,手动时首先触发TextEdited()信号,然后自动触发TextChanged()信号。所以我不希望TextChanged()信号在TextEdited()信号之后触发。程序代码已被简化,以便更好地理解问题。