Fra*_*itz 9 c++ qt qtquickcontrols2
我用Qt Quick Controls 2.0用鼠标在TextField上选择文本时遇到了困难.当我将鼠标悬停在TextField上时,光标不会从光标箭头变为光标I beam,我无法选择文本.我通过使用键盘快捷键Ctrl + A验证了文本选择.我还使用Qt Quick Controls 1.4中的TextField进行了测试,它按预期工作(鼠标光标变为I光束,我可以选择文本).我想我必须遗漏一些明显的东西,因为这看起来像基本的文本字段功能.有没有人有任何想法?以下是我的代码:
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
}
}
Run Code Online (Sandbox Code Playgroud)
您可以使用它selectByMouse: true来启用鼠标选择.在嵌入式和移动平台上通常不需要这样做.至于鼠标光标,它将在Qt 5.7.1中修复.作为临时解决方法,您可以使用MouseArea.
TextField {
selectByMouse: true
MouseArea {
anchors.fill: parent
cursorShape: Qt.IBeamCursor
acceptedButtons: Qt.NoButton
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2911 次 |
| 最近记录: |