I'm having difficulty with selecting text on a 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 from Qt Quick Controls 1.4, and it works as expected (the mouse cursor changes to an I beam and I can select text). I think I must be missing something obvious because this seems like basic text field functionality. Does anyone have any ideas? Below is my code:
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
}
}
You can use selectByMouse: true
to enable mouse selection. This is typically not desired on embedded and mobile platforms. As for the mouse cursor, it will be fixed in Qt 5.7.1. As a temporary workaround, you can use a MouseArea
.
TextField {
selectByMouse: true
MouseArea {
anchors.fill: parent
cursorShape: Qt.IBeamCursor
acceptedButtons: Qt.NoButton
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With