From f92ca8323029fe3f935c4410a6fb6a895b40f903 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 21 Jan 2019 10:30:10 +0100 Subject: 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 --- src/widgets/dialogs/qinputdialog.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/widgets/dialogs/qinputdialog.cpp') 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); -- cgit v1.2.3