diff options
author | Andy Shaw <andy.shaw@qt.io> | 2019-01-21 10:30:10 +0100 |
---|---|---|
committer | Andy Shaw <andy.shaw@qt.io> | 2019-01-28 15:26:27 +0000 |
commit | f92ca8323029fe3f935c4410a6fb6a895b40f903 (patch) | |
tree | 96b0982cf922f78b7afb1998785bb767136a841d | |
parent | 112278d3d719ebb3ade00a8e63eb16abd4a29550 (diff) |
Don't enable the input method for the QListView in a QInputDialog
As the listview in an input dialog is only used for selecting the entry
in place of a combobox, then we should prevent the input method from
being enabled. This ensures that it does not show an invalid text
cursor on devices like iOS and Android.
Change-Id: Ifb854e509573ec2d63d4cbcfa61335ae5b251ab5
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
-rw-r--r-- | src/widgets/dialogs/qinputdialog.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/widgets/dialogs/qinputdialog.cpp b/src/widgets/dialogs/qinputdialog.cpp index 5a7d6edddf..3cfe8367e0 100644 --- a/src/widgets/dialogs/qinputdialog.cpp +++ b/src/widgets/dialogs/qinputdialog.cpp @@ -168,6 +168,18 @@ private: } }; +class QInputDialogListView : public QListView +{ +public: + QInputDialogListView(QWidget *parent = 0) : QListView(parent) {} + QVariant inputMethodQuery(Qt::InputMethodQuery query) const override + { + if (query == Qt::ImEnabled) + return false; + return QListView::inputMethodQuery(query); + } +}; + class QInputDialogPrivate : public QDialogPrivate { Q_DECLARE_PUBLIC(QInputDialog) @@ -201,7 +213,7 @@ public: mutable QSpinBox *intSpinBox; mutable QDoubleSpinBox *doubleSpinBox; mutable QComboBox *comboBox; - mutable QListView *listView; + mutable QInputDialogListView *listView; mutable QWidget *inputWidget; mutable QVBoxLayout *mainLayout; QInputDialog::InputDialogOptions opts; @@ -298,8 +310,7 @@ void QInputDialogPrivate::ensureListView() Q_Q(QInputDialog); if (!listView) { ensureComboBox(); - - listView = new QListView(q); + listView = new QInputDialogListView(q); listView->hide(); listView->setEditTriggers(QAbstractItemView::NoEditTriggers); listView->setSelectionMode(QAbstractItemView::SingleSelection); |