本文整理汇总了C++中QSortFilterProxyModel::setFilterRegExp方法的典型用法代码示例。如果您正苦于以下问题:C++ QSortFilterProxyModel::setFilterRegExp方法的具体用法?C++ QSortFilterProxyModel::setFilterRegExp怎么用?C++ QSortFilterProxyModel::setFilterRegExp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSortFilterProxyModel
的用法示例。
在下文中一共展示了QSortFilterProxyModel::setFilterRegExp方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWidget
Widget::Widget(QWidget *parent)
: QWidget(parent)
{
//! [0] //! [1]
QTreeView *treeView = new QTreeView;
//! [0]
MyItemModel *model = new MyItemModel(this);
treeView->setModel(model);
//! [1]
//! [2]
MyItemModel *sourceModel = new MyItemModel(this);
QSortFilterProxyModel *proxyModel = new QSortFilterProxyModel(this);
proxyModel->setSourceModel(sourceModel);
treeView->setModel(proxyModel);
//! [2]
//! [3]
treeView->setSortingEnabled(true);
//! [3]
//! [4]
proxyModel->sort(2, Qt::AscendingOrder);
//! [4] //! [5]
proxyModel->setFilterRegExp(QRegExp(".png", Qt::CaseInsensitive,
QRegExp::FixedString));
proxyModel->setFilterKeyColumn(1);
//! [5]
}
示例2: stringListModel
void tst_ModelTest::stringListModel()
{
QStringListModel model;
QSortFilterProxyModel proxy;
ModelTest t1(&model);
ModelTest t2(&proxy);
proxy.setSourceModel(&model);
model.setStringList(QStringList() << "2" << "3" << "1");
model.setStringList(QStringList() << "a" << "e" << "plop" << "b" << "c" );
proxy.setDynamicSortFilter(true);
proxy.setFilterRegExp(QRegExp("[^b]"));
}
示例3: onUpdateCategoryVisibled
void CMessageDock::onUpdateCategoryVisibled()
{
QSortFilterProxyModel* model
= static_cast<QSortFilterProxyModel*>(m_listWidget->model()) ;
QString re;
if( m_visibledErrorAction->isChecked() ) { re += "|" + tr("Error"); }
if( m_visibledWarningAction->isChecked() ) { re += "|" + tr("Warning"); }
if( m_visibledInfomationAction->isChecked() ) { re += "|" + tr("Information"); }
re = "^(" + re.mid(1) + ")$";
model->setFilterRegExp(QRegExp(re));
}
示例4: ui
PokeSelection::PokeSelection(Pokemon::uniqueId pokemon, QAbstractItemModel *pokemonModel) :
ui(new Ui::PokeSelection), search(NULL), newwidth(0)
{
ui->setupUi(this);
QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this);
proxy->setFilterRegExp(".");
proxy->setSourceModel(pokemonModel);
this->sourceModel = pokemonModel;
this->proxy = proxy;
ui->pokemonList->setModel(proxy);
QCompleter *completer = new QCompleter(proxy, ui->pokeEdit);
completer->setCompletionColumn(1);
completer->setCompletionRole(Qt::DisplayRole);
completer->setCaseSensitivity(Qt::CaseInsensitive);
completer->setCompletionMode(QCompleter::PopupCompletion);
ui->pokeEdit->setCompleter(completer);
setNum(pokemon);
ui->pokemonList->setCurrentIndex(pokemonModel->index(pokemon.pokenum, 1));
ui->pokemonList->scrollTo(ui->pokemonList->currentIndex());
updateSprite();
updateTypes();
if (getGen() <= 1) {
ui->shiny->hide();
} else {
ui->shiny->show();
}
ui->baseStats->setGen(getGen());
connect(completer, SIGNAL(activated(QModelIndex)), SLOT(setPokemon(QModelIndex)));
connect(ui->shiny, SIGNAL(toggled(bool)), SLOT(updateSprite()));
connect(ui->pokemonList, SIGNAL(pokemonSelected(Pokemon::uniqueId)), SLOT(setNum(Pokemon::uniqueId)));
connect(ui->pokemonList, SIGNAL(pokemonSelected(Pokemon::uniqueId)), SLOT(updateSprite()));
connect(ui->pokemonList, SIGNAL(pokemonSelected(Pokemon::uniqueId)), SLOT(updateTypes()));
connect(ui->pokemonList, SIGNAL(pokemonActivated(Pokemon::uniqueId)), SLOT(finish()));
connect(ui->changeSpecies, SIGNAL(clicked()), SLOT(finish()));
connect(ui->pokemonFrame, SIGNAL(clicked()), SLOT(toggleSearchWindow()));
}
示例5: testAdditionalLink
void KLinkItemSelectionModelTest::testAdditionalLink()
{
#if QT_VERSION >= QT_VERSION_CHECK(5, 5, 0)
{
auto idx = m_mainModel->index(6, 0);
m_mainSelectionModel->select(idx, QItemSelectionModel::Select);
}
QVERIFY(!m_mainSelectionModel->selection().isEmpty());
QVERIFY(!m_subSelectionModel->selection().isEmpty());
QCOMPARE(m_mainSelectionModel->selection().indexes().first().row(), 6);
QCOMPARE(m_subSelectionModel->selection().indexes().first().row(), 1);
{
QSortFilterProxyModel additionalProxy;
additionalProxy.setFilterRegExp(QRegExp(QStringLiteral("^[3-9]")));
additionalProxy.setSourceModel(m_mainModel);
KLinkItemSelectionModel additionalLink;
additionalLink.setModel(&additionalProxy);
additionalLink.setLinkedItemSelectionModel(m_mainSelectionModel);
QVERIFY(!additionalLink.selection().isEmpty());
QCOMPARE(additionalLink.selection().indexes().first().row(), 3);
auto idx = additionalProxy.index(4, 0);
QVERIFY(idx.isValid());
additionalLink.select(idx, QItemSelectionModel::ClearAndSelect);
QVERIFY(!additionalLink.selection().isEmpty());
QCOMPARE(additionalLink.selection().indexes().first().row(), 4);
QVERIFY(!m_mainSelectionModel->selection().isEmpty());
QVERIFY(!m_subSelectionModel->selection().isEmpty());
QCOMPARE(m_mainSelectionModel->selection().indexes().first().row(), 7);
QCOMPARE(m_subSelectionModel->selection().indexes().first().row(), 2);
}
QVERIFY(!m_mainSelectionModel->selection().isEmpty());
QVERIFY(!m_subSelectionModel->selection().isEmpty());
QCOMPARE(m_mainSelectionModel->selection().indexes().first().row(), 7);
QCOMPARE(m_subSelectionModel->selection().indexes().first().row(), 2);
#endif
}
示例6: QWidget
//------------------------------------------------------------------------------
AnalysisSummaryWidget::AnalysisSummaryWidget(QSharedPointer<BudgetingPeriod> period,
ProjectedBalanceModel* balances, EstimateDiffsModel* over,
EstimateDiffsModel* under, QWidget* parent)
: QWidget(parent)
{
importSource = new QLineEdit(tr("None"));
importSource->setReadOnly(true);
importCount = new QLineEdit("0");
importCount->setReadOnly(true);
assignedCount = new QLineEdit("0");
assignedCount->setReadOnly(true);
overBudgetCount = new QLineEdit("0");
overBudgetCount->setReadOnly(true);
underBudgetCount = new QLineEdit("0");
underBudgetCount->setReadOnly(true);
QFormLayout* formLayout = new QFormLayout;
formLayout->addRow(tr("Import Source"), importSource);
formLayout->addRow(tr("Number of Imported Transactions"), importCount);
formLayout->addRow(tr("Number of Assigned Transactions"), assignedCount);
formLayout->addRow(tr("Number of Over-budget Estimates"), overBudgetCount);
formLayout->addRow(tr("Number of Under-budget Estimates"), underBudgetCount);
QTableView* balanceTable = new QTableView(this);
balanceTable->setModel(balances);
balanceTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
balanceTable->setSelectionBehavior(QTableView::SelectRows);
QTableView* overBudgetTable = new QTableView(this);
QSortFilterProxyModel* overModel = new QSortFilterProxyModel(this);
overModel->setSourceModel(over);
overBudgetTable->setModel(overModel);
overBudgetTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
overBudgetTable->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
overBudgetTable->setSelectionBehavior(QTableView::SelectRows);
overBudgetTable->hideColumn(0);
// Only show expense estimates
overModel->setFilterKeyColumn(0);
overModel->setFilterRegExp(QRegExp(QString("%1").arg(Estimate::Expense)));
QTableView* underBudgetTable = new QTableView(this);
QSortFilterProxyModel* underModel = new QSortFilterProxyModel(this);
underModel->setSourceModel(under);
underBudgetTable->setModel(underModel);
underBudgetTable->horizontalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);
underBudgetTable->horizontalHeader()->setSectionResizeMode(1, QHeaderView::Stretch);
underBudgetTable->setSelectionBehavior(QTableView::SelectRows);
underBudgetTable->hideColumn(0);
// Only show expense estimates
underModel->setFilterKeyColumn(0);
underModel->setFilterRegExp(QRegExp(QString("%1").arg(Estimate::Expense)));
QVBoxLayout* layout = new QVBoxLayout(this);
layout->addLayout(formLayout);
layout->addWidget(new QLabel(tr("Projected Ending Balances")));
layout->addWidget(balanceTable);
layout->addWidget(new QLabel(tr("Top Over-budget Estimates")));
layout->addWidget(overBudgetTable);
layout->addWidget(new QLabel(tr("Top Under-budget Estimates")));
layout->addWidget(underBudgetTable);
setLayout(layout);
}
示例7: searchEditChanged
void ContactsTable::searchEditChanged(QString search_string)
{
QSortFilterProxyModel* model = dynamic_cast<QSortFilterProxyModel*>(ui->contact_table->model());
QRegExp regex(search_string, Qt::CaseInsensitive, QRegExp::FixedString);
model->setFilterRegExp(regex);
}
示例8: ui
PokeEdit::PokeEdit(TeamBuilderWidget *master, PokeTeam *poke, QAbstractItemModel *pokeModel, QAbstractItemModel *itemsModel, QAbstractItemModel *natureModel) :
ui(new Ui::PokeEdit),
pokemonModel(pokeModel),
m_poke(poke), master(master)
{
ui->setupUi(this);
ui->itemSprite->raise();
ui->item->setModel(itemsModel);
ui->nature->setModel(natureModel);
ui->levelSettings->setPoke(poke);
ui->evbox->setPoke(poke);
ui->ivbox->setPoke(poke);
if (0) {
master->getDock(EVDock)->setWidget(ui->evbox);
master->getDock(IVDock)->setWidget(ui->ivbox);
master->getDock(LevelDock)->setWidget(ui->levelSettings);
master->getDock(MoveDock)->setWidget(ui->moveContainer);
} else {
QCloseDockWidget *hi = new QCloseDockWidget(tr("Advanced"), this);
hi->setObjectName("AdvancedTab");
hi->setWidget(ui->ivbox);
hi->setFeatures(QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetMovable);
ui->horizontalMove->addWidget(hi);
if (advancedWindowClosed) {
hi->close();
}
connect(hi, SIGNAL(closed()), SIGNAL(closeAdvanced()));
// QDockWidget *hi2 = new QDockWidget(tr("Level"), this);
// hi2->setWidget(ui->levelSettings);
// hi2->setFeatures(QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetMovable);
// ui->horizontalPoke->addWidget(hi2);
}
QSortFilterProxyModel *pokeFilter = new QSortFilterProxyModel(this);
pokeFilter->setFilterRegExp(".");
pokeFilter->setSourceModel(pokemonModel);
QCompleter *completer = new QCompleter(pokeFilter, ui->nickname);
completer->setCompletionColumn(1);
completer->setCompletionRole(Qt::DisplayRole);
completer->setCaseSensitivity(Qt::CaseInsensitive);
completer->setCompletionMode(QCompleter::PopupCompletion);
ui->nickname->setCompleter(completer);
connect(completer, SIGNAL(activated(QString)), SLOT(setNum(QString)));
/* 20 characters for the name. Longest name: Vivillon-Archipelago = 20 characters */
ui->nickname->setValidator(new QNickValidator(ui->nickname, 20));
fillMoves();
connect(ui->levelSettings, SIGNAL(levelUpdated()), this, SLOT(updateStats()));
connect(ui->levelSettings, SIGNAL(levelUpdated()), ui->ivbox, SLOT(updateStats()));
connect(ui->levelSettings, SIGNAL(genderUpdated()), this, SLOT(updatePicture()));
connect(ui->levelSettings, SIGNAL(genderUpdated()), this, SLOT(updateGender()));
connect(ui->ivbox, SIGNAL(genderUpdated()), SLOT(updateGender()));
connect(ui->ivbox, SIGNAL(genderUpdated()), ui->levelSettings, SLOT(updateGender()));
connect(ui->ivbox, SIGNAL(shinyUpdated()), SLOT(updatePicture()));
connect(ui->happiness, SIGNAL(valueChanged(int)), this, SLOT(changeHappiness(int)));
connect(ui->nature, SIGNAL(currentIndexChanged(int)), this, SLOT(changeNature(int)));
connect(ui->item, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeItem(QString)));
connect(ui->evbox, SIGNAL(natureChanged(int)), this, SLOT(setNature(int)));
connect(ui->evbox, SIGNAL(natureBoostChanged()), ui->ivbox, SLOT(updateStats()));
connect(ui->ivbox, SIGNAL(statsUpdated()), ui->evbox, SLOT(updateEVs()));
updateAll();
}