Qt输出警告: Unhandled QCompleter::filterMode flag is used.

查看源码qtbase/src/widgets/util/qcompleter.cpp,在源码中找到了输出警告的原因。

 1 void QCompleter::setFilterMode(Qt::MatchFlags filterMode)
 2 {
 3     Q_D(QCompleter);
 4     if (d->filterMode == filterMode)
 5         return;
 6     if (Q_UNLIKELY(filterMode != Qt::MatchStartsWith &&
 7                    filterMode != Qt::MatchContains &&
 8                    filterMode != Qt::MatchEndsWith)) {
 9         qWarning("Unhandled QCompleter::filterMode flag is used.");
10         return;
11     }
12     d->filterMode = filterMode;
13     d->proxy->createEngine();
14     d->proxy->invalidate();
15 }

我设置过滤模式的代码:

m_pCompleter->setFilterMode(Qt::MatchRecursive);

将Qt::MatchRecursive改为Qt::MatchStartsWith或Qt::MatchContains或Qt::MatchEndsWith就不输出警告了。

如:

m_pCompleter->setFilterMode(Qt::MatchContains);
 
原文地址:https://www.cnblogs.com/grebamboo/p/14178948.html