【发布时间】:2018-02-05 14:18:03
【问题描述】:
在我的项目中,我使用 QML TextField。我想在使用长字符串时正确表示光标。主要问题出现了,当我们将光标设置在字符串的中间并开始输入文本时。在这种情况下,文本出现在光标的左侧,但它不会移动光标!我想在输入文本时创建光标移动到右侧,直到它到达右侧。
TextField {
font.pixelSize: parent.height * 0.7
anchors.fill: parent
anchors.verticalCenter: parent.verticalCenter
text: parent.text
cursorPosition: parent.cursorPosition
cursorVisible: true
}
【问题讨论】:
-
已经尝试您的代码消除了
text: parent.text和cursorPosition: parent.cursorPosition并且它工作正常,您可以提供一个minimal reproducible example,例如,当我运行您的代码时,我收到一个错误,因为没有定义父级,也不是你指出父母是什么类型。