Qt Quick Controls 2.0 文本字段不能 Select 文本
Qt Quick Controls 2.0 Text Field Cannot Select Text
我在 Qt Quick Controls 1.4 的 TextField from Qt Quick Controls 2.0 with a mouse. When I hover over the TextField the cursor does not change from the cursor arrow to the cursor I beam and I am unable to select text. I verified text selection is possible by using the keyboard shortcut Ctrl+A. I also tested this with the TextField 上 select 编辑文本时遇到困难,但它按预期工作(鼠标光标变为 I 形,我可以 select 文本)。我想我一定遗漏了一些明显的东西,因为这看起来像是基本的文本字段功能。有人有什么想法吗?下面是我的代码:
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
TextField {
anchors.centerIn: parent
height: 50
width: 100
}
}
您可以使用selectByMouse: true
启用鼠标选择。这在嵌入式和移动平台上通常是不需要的。至于鼠标光标,它将在 Qt 5.7.1 中修复。作为临时解决方法,您可以使用 MouseArea
.
TextField {
selectByMouse: true
MouseArea {
anchors.fill: parent
cursorShape: Qt.IBeamCursor
acceptedButtons: Qt.NoButton
}
}
TextField
现在有 属性 selectByMouse
,所以启用它就足够了。
TextField {
anchors.centerIn: parent
height: 50
width: 100
selectByMouse: true
}
我在 Qt Quick Controls 1.4 的 TextField from Qt Quick Controls 2.0 with a mouse. When I hover over the TextField the cursor does not change from the cursor arrow to the cursor I beam and I am unable to select text. I verified text selection is possible by using the keyboard shortcut Ctrl+A. I also tested this with the TextField 上 select 编辑文本时遇到困难,但它按预期工作(鼠标光标变为 I 形,我可以 select 文本)。我想我一定遗漏了一些明显的东西,因为这看起来像是基本的文本字段功能。有人有什么想法吗?下面是我的代码:
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
TextField {
anchors.centerIn: parent
height: 50
width: 100
}
}
您可以使用selectByMouse: true
启用鼠标选择。这在嵌入式和移动平台上通常是不需要的。至于鼠标光标,它将在 Qt 5.7.1 中修复。作为临时解决方法,您可以使用 MouseArea
.
TextField {
selectByMouse: true
MouseArea {
anchors.fill: parent
cursorShape: Qt.IBeamCursor
acceptedButtons: Qt.NoButton
}
}
TextField
现在有 属性 selectByMouse
,所以启用它就足够了。
TextField {
anchors.centerIn: parent
height: 50
width: 100
selectByMouse: true
}