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>
This commit is contained in:
parent
112278d3d7
commit
f92ca83230
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user