带有Qt.MatchRegExp的QCompleter无法正常工作

时间:2019-07-02 19:18:32

标签: python pyqt pyqt5 qcompleter

我想自定义QCompleter,使其支持通配符和正则表达式搜索。但是,当我使用setFilterMode(Qt.MatchRegExp)时,会弹出警告:Unhandled QCompleter::filterMode flag is used.当我查看Qt源代码时,它是

/*!
    \property QCompleter::filterMode
    \brief how the filtering is performed
    \since 5.2
    If filterMode is set to Qt::MatchStartsWith, only those entries that start
    with the typed characters will be displayed. Qt::MatchContains will display
    the entries that contain the typed characters, and Qt::MatchEndsWith the
    ones that end with the typed characters.
    Currently, only these three modes are implemented. Setting filterMode to
    any other Qt::MatchFlag will issue a warning, and no action will be
    performed.
    The default mode is Qt::MatchStartsWith.
*/
void QCompleter::setFilterMode(Qt::MatchFlags filterMode)
{
    Q_D(QCompleter);
    if (d->filterMode == filterMode)
        return;
    if (Q_UNLIKELY(filterMode != Qt::MatchStartsWith &&
                   filterMode != Qt::MatchContains &&
                   filterMode != Qt::MatchEndsWith)) {
        qWarning("Unhandled QCompleter::filterMode flag is used.");
        return;
    }
    d->filterMode = filterMode;
    d->proxy->createEngine();
    d->proxy->invalidate();
}

那我该如何自定义我的QCompleter?预先感谢。

0 个答案:

没有答案