diff options
-rw-r--r-- | src/widgets/util/qcompleter_p.h | 3 | ||||
-rw-r--r-- | src/widgets/widgets/qcombobox.cpp | 15 | ||||
-rw-r--r-- | src/widgets/widgets/qwidgetlinecontrol.cpp | 11 |
3 files changed, 18 insertions, 11 deletions
diff --git a/src/widgets/util/qcompleter_p.h b/src/widgets/util/qcompleter_p.h index 40b08cc20a..5b89f9d8b5 100644 --- a/src/widgets/util/qcompleter_p.h +++ b/src/widgets/util/qcompleter_p.h @@ -101,6 +101,9 @@ public: void _q_autoResizePopup(); void _q_fileSystemModelDirectoryLoaded(const QString &path); void setCurrentIndex(QModelIndex, bool = true); + + static QCompleterPrivate *get(QCompleter *o) { return o->d_func(); } + static const QCompleterPrivate *get(const QCompleter *o) { return o->d_func(); } }; class QIndexMapper diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index b6bb31c391..54d33a7eea 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -71,6 +71,7 @@ #include <private/qabstractitemmodel_p.h> #include <private/qabstractscrollarea_p.h> #include <private/qlineedit_p.h> +#include <private/qcompleter_p.h> #include <qdebug.h> #if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && QT_CONFIG(effetcts) && QT_CONFIG(style_mac) #include <private/qcore_mac_p.h> @@ -3140,13 +3141,13 @@ void QComboBox::keyPressEvent(QKeyEvent *e) Q_D(QComboBox); #if QT_CONFIG(completer) - if (d->lineEdit - && d->lineEdit->completer() - && d->lineEdit->completer()->popup() - && d->lineEdit->completer()->popup()->isVisible()) { - // provide same autocompletion support as line edit - d->lineEdit->event(e); - return; + if (const auto *cmpltr = completer()) { + const auto *popup = QCompleterPrivate::get(cmpltr)->popup; + if (popup && popup->isVisible()) { + // provide same autocompletion support as line edit + d->lineEdit->event(e); + return; + } } #endif diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index 1b7a41d547..32944b3918 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -44,6 +44,7 @@ #endif #include "qclipboard.h" #include <private/qguiapplication_p.h> +#include <private/qcompleter_p.h> #include <qpa/qplatformtheme.h> #include <qstylehints.h> #ifndef QT_NO_ACCESSIBILITY @@ -1484,7 +1485,8 @@ void QWidgetLineControl::complete(int key) } else { #ifndef QT_KEYPAD_NAVIGATION if (text.isEmpty()) { - m_completer->popup()->hide(); + if (auto *popup = QCompleterPrivate::get(m_completer)->popup) + popup->hide(); return; } #endif @@ -1630,10 +1632,10 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) #if QT_CONFIG(completer) if (m_completer) { QCompleter::CompletionMode completionMode = m_completer->completionMode(); + auto *popup = QCompleterPrivate::get(m_completer)->popup; if ((completionMode == QCompleter::PopupCompletion || completionMode == QCompleter::UnfilteredPopupCompletion) - && m_completer->popup() - && m_completer->popup()->isVisible()) { + && popup && popup->isVisible()) { // The following keys are forwarded by the completer to the widget // Ignoring the events lets the completer provide suitable default behavior switch (event->key()) { @@ -1648,7 +1650,8 @@ void QWidgetLineControl::processKeyEvent(QKeyEvent* event) if (!QApplication::keypadNavigationEnabled()) break; #endif - m_completer->popup()->hide(); // just hide. will end up propagating to parent + popup->hide(); // just hide. will end up propagating to parent + break; default: break; // normal key processing } |