本文整理汇总了C++中QCompleter::setFilterMode方法的典型用法代码示例。如果您正苦于以下问题:C++ QCompleter::setFilterMode方法的具体用法?C++ QCompleter::setFilterMode怎么用?C++ QCompleter::setFilterMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCompleter
的用法示例。
在下文中一共展示了QCompleter::setFilterMode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: showCommands
void Omnibar::showCommands() {
this->setFocus();
this->setText(": ");
QCompleter *completer = this->completer();
completer->setCompletionMode(QCompleter::PopupCompletion);
completer->setModelSorting(QCompleter::CaseSensitivelySortedModel);
completer->setCaseSensitivity(Qt::CaseInsensitive);
completer->setFilterMode(Qt::MatchStartsWith);
completer->setMaxVisibleItems(20);
completer->setCompletionPrefix(": ");
completer->complete();
}
示例2: setupCompleter
void Omnibar::setupCompleter() {
// Set gotoEntry completer for jump history
QStringList flagsList = this->getFlags();
QCompleter *completer = new QCompleter(flagsList, this);
completer->setMaxVisibleItems(20);
completer->setCompletionMode(QCompleter::PopupCompletion);
completer->setModelSorting(QCompleter::CaseSensitivelySortedModel);
completer->setCaseSensitivity(Qt::CaseInsensitive);
completer->setFilterMode(Qt::MatchContains);
QStringListModel *completerModel = (QStringListModel*)(completer->model());
completerModel->setStringList(completerModel->stringList() << this->commands);
this->setCompleter(completer);
}
示例3: slotModelDataChanged
void CStudentManage::slotModelDataChanged(QModelIndex, QModelIndex, QVector<int>)
{
//遍历整个记录集
QStringList StrList;
for (int i = 0; i < m_Model->rowCount(); ++i)
{
QSqlRecord record = m_Model->record(i);
for (int j = 0; j < record.count(); ++j)
{
QVariant var = record.value(j);
if (var.isNull())
continue;
StrList << var.toString();
}
}
//将记录集 设置到edit的匹配中
QCompleter *completer = new QCompleter(StrList, this);
completer->setFilterMode(Qt::MatchContains);
m_Edit->setCompleter(completer);
}
示例4: QMainWindow
//.........这里部分代码省略.........
auto MakeHitterFilter = [=](QString text, QString toolTip, const auto& onFilterFn) -> QAction*
{
QAction* action = new QAction(this);
connect(action, &QAction::toggled, hitterSortFilterProxyModel, onFilterFn);
action->setText(text);
action->setToolTip(toolTip);
action->setCheckable(true);
action->toggle();
hittingFilters->addAction(action);
return action;
};
// Hitter filters
QAction* filterC = MakeHitterFilter("C", "Filter Catchers", &PlayerSortFilterProxyModel::OnFilterC);
QAction* filter1B = MakeHitterFilter("1B", "Filter 1B", &PlayerSortFilterProxyModel::OnFilter1B);
QAction* filter2B = MakeHitterFilter("2B", "Filter 2B", &PlayerSortFilterProxyModel::OnFilter2B);
QAction* filterSS = MakeHitterFilter("SS", "Filter SS", &PlayerSortFilterProxyModel::OnFilterSS);
QAction* filter3B = MakeHitterFilter("3B", "Filter 3B", &PlayerSortFilterProxyModel::OnFilter3B);
QAction* filterOF = MakeHitterFilter("OF", "Filter Outfielders", &PlayerSortFilterProxyModel::OnFilterOF);
QAction* filterCI = MakeHitterFilter("CI", "Filter Corner Infielders", &PlayerSortFilterProxyModel::OnFilterCI);
QAction* filterMI = MakeHitterFilter("MI", "Filter Middle Infielders", &PlayerSortFilterProxyModel::OnFilterMI);
QAction* filterDH = MakeHitterFilter("DH", "Filter Designated Hitters", &PlayerSortFilterProxyModel::OnFilterDH);
QAction* filterU = MakeHitterFilter("U", "Filter Utility", &PlayerSortFilterProxyModel::OnFilterU);
// Menu spacer
QWidget* spacer = new QWidget(this);
spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
// Completion Widget
QCompleter* completer = new QCompleter(this);
completer->setModel(playerTableModel);
completer->setCompletionColumn(PlayerTableModel::COLUMN_NAME);
completer->setFilterMode(Qt::MatchContains);
completer->setCaseSensitivity(Qt::CaseInsensitive);
// Select
auto HighlightPlayerInTable = [=](const QModelIndex& srcIdx)
{
// Lookup catergory
auto catergoryIdx = srcIdx.model()->index(srcIdx.row(), PlayerTableModel::COLUMN_CATERGORY);
auto catergory = srcIdx.model()->data(catergoryIdx).toUInt();
// Change to tab
hitterPitcherTabs->setCurrentIndex(CaterogyToTab(catergory));
// Select row
if (catergory == Player::Catergory::Hitter) {
auto proxyModel = dynamic_cast<QSortFilterProxyModel*>(hitterTableView->model());
auto proxyIdx = proxyModel->mapFromSource(srcIdx);
hitterTableView->selectRow(proxyIdx.row());
hitterTableView->setFocus();
} else if (catergory == Player::Catergory::Pitcher) {
auto proxyModel = dynamic_cast<QSortFilterProxyModel*>(pitcherTableView->model());
auto proxyIdx = proxyModel->mapFromSource(srcIdx);
pitcherTableView->selectRow(proxyIdx.row());
pitcherTableView->setFocus();
}
};
// Select the target
connect(completer, static_cast<void (QCompleter::*)(const QModelIndex&)>(&QCompleter::activated), [=](const QModelIndex& index) {
// Get player index
QAbstractProxyModel* proxyModel = dynamic_cast<QAbstractProxyModel*>(completer->completionModel());
auto srcIdx = proxyModel->mapToSource(index);
示例5: restoreCompleter
void Omnibar::restoreCompleter()
{
QCompleter *completer = this->completer();
completer->setFilterMode(Qt::MatchContains);
}