tabChangesFocus property in TextArea is not working
-
As explained in documentation here: http://doc.qt.io/qt-5/qml-qtquick-controls-textarea.html#tabChangesFocus-prop
I expect the Tab key in TextArea to be accepted as input not to change the focus. But in my QML code below, whatever tabChangesFocus value assigned, it keep changing the focus into next element. I use Qt 5.4 and qmlscene to preview the QML file.
import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Layouts 1.1 ColumnLayout { id: columnLayout1 RowLayout { id: rowLayout1 anchors.top: parent.top anchors.topMargin: 0 anchors.left: parent.left anchors.right: parent.right TextField { id: textField1 placeholderText: qsTr("Text Field") Layout.fillWidth: true } Button { id: btnAdd text: qsTr("Add") } Button { id: btnClose text: qsTr("Close") } } TextArea { id: textArea1 Layout.fillHeight: true anchors.bottom: parent.bottom anchors.bottomMargin: 0 anchors.right: parent.right anchors.rightMargin: 0 anchors.left: parent.left anchors.leftMargin: 0 tabChangesFocus: false } }
-
Hi @advent,
It is a known bug. See QTBUG-39102. Still unresolved. -
@p3c0 Sorry, that's not what I really mean. I want to force the TextArea (if it's possible) to accept
Tab
key as character. I know insertingTab
character in TextArea can be done withCtrl+Tab
, but I don't like that. The bug has been there for like a year. Is there any workaround?Btw, I tried to override the
Tab
key behavior in QML, but it's just doesn't work. Is this correct way to overrideTab
key?TextArea { id: textArea ... Keys.onPressed: { if (event.key == Qt.Key_Tab) { textArea.insert(/*current_position*/, "\t"); } } }