gpt4 book ai didi

qt - 在 QML 中将 TextArea 光标移动到 MouseArea 单击上

转载 作者:行者123 更新时间:2023-12-02 20:41:34 25 4
gpt4 key购买 nike

有一个 TextArea,我已将 activeFocusOnPress 属性设置为 false 以阻止虚拟键盘弹出,但是当用户单击 TextArea 时,光标位置应该移动。为了实现这一目标,我认为 mousearea 将是一个不错的选择。代码如下:

TextArea{
id:textArea
text:"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
width:100
height: 200
color: "white"
cursorVisible: true
activeFocusOnPress: false //To Block virtual Keyboard popup

background: Rectangle{
color:"transparent"
border.color : "white"
border.width:2
MouseArea{
id:mousearea
anchors.fill:parent
onClicked: {

//*** How to set cursor position??
}
}
}
}

最佳答案

这个怎么样?

textArea.cursorPosition = textArea.positionAt(mouseX, mouseY)

关于qt - 在 QML 中将 TextArea 光标移动到 MouseArea 单击上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45993966/

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