Я использую в своем коде свойство KeyNavigation.tab
, чтобы навигация работала в qml.
Но элемент управления SpinBox
не работает с ним.например, если у меня есть элемент управления между ним и элементом, по которому я хочу, чтобы он перемещался, он не будет соблюдать правило.
Я собираюсь проиллюстрировать реальным примером.
main.cpp
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
if (engine.rootObjects().isEmpty())
return -1;
return app.exec();
}
и
main.qml
import QtQuick 2.9
import QtQuick.Controls 1.4
import QtQuick.Controls 2.0
ApplicationWindow {
id: window
title: "Stack"
visible: true
height: 200
width: 400
Item {
id: page
anchors.fill: parent
width:parent.width
height: parent.height
ScrollView {
id:scrollView
anchors.fill:parent
Column{
width:parent.width
spacing:10
TextField {
id:textField
KeyNavigation.tab: spinBox1
implicitHeight: 30
font.bold: true
}
SpinBox {
id: spinBox1
KeyNavigation.tab: spinBox2
width: 100
height: 30
editable: true
}
ComboBox {
id:comboBox
//KeyNavigation.tab: spinBox2
anchors.topMargin: 10
textRole: "text"
}
SpinBox {
id: spinBox2
KeyNavigation.tab: textField
width: 100
height: 30
editable: true
}
}
}
}
}
Здесь spinBox1
не будет переходить на spinBox2
, если мы будем использовать tab.
Это былопротестировано на ОС Windows 10
Используемая версия Qt - 5.11.1