Warn when setting a completer on non-editable QComboBox

This is not valid, but was confusing before and would be silently ignored,
warn instead.

Fixes: QTBUG-50583
Change-Id: If78c4a5ef96c76e1d5116a1bd24e5c289ff74cc4
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
Frederik Gladhorn 2018-10-17 22:12:43 +02:00
parent f5962d05d3
commit 64f6169f61

View File

@ -1941,12 +1941,15 @@ const QValidator *QComboBox::validator() const
performs case insensitive inline completion is automatically created.
\note The completer is removed when the \l editable property becomes \c false.
Setting a completer on a QComboBox that is not editable will be ignored.
*/
void QComboBox::setCompleter(QCompleter *c)
{
Q_D(QComboBox);
if (!d->lineEdit)
if (!d->lineEdit) {
qWarning("Setting a QCompleter on non-editable QComboBox is not allowed.");
return;
}
d->lineEdit->setCompleter(c);
if (c) {
connect(c, SIGNAL(activated(QModelIndex)), this, SLOT(_q_completerActivated(QModelIndex)));