本文整理汇总了C++中QSortFilterProxyModel::setFilterKeyColumn方法的典型用法代码示例。如果您正苦于以下问题:C++ QSortFilterProxyModel::setFilterKeyColumn方法的具体用法?C++ QSortFilterProxyModel::setFilterKeyColumn怎么用?C++ QSortFilterProxyModel::setFilterKeyColumn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSortFilterProxyModel
的用法示例。
在下文中一共展示了QSortFilterProxyModel::setFilterKeyColumn方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: QTreeView
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false),
currentHeaderClicked(-1), searchBox(new QLineEdit(this))
{
setUniformRowHeights(true);
setItemDelegateForColumn(TreeItemDT::RATING, new StarWidgetsDelegate());
QSortFilterProxyModel *model = new QSortFilterProxyModel(this);
model->setSortRole(TreeItemDT::SORT_ROLE);
model->setFilterKeyColumn(-1); // filter all columns
setModel(model);
connect(model, SIGNAL(layoutChanged()), this, SLOT(fixMessyQtModelBehaviour()));
setSortingEnabled(false);
setContextMenuPolicy(Qt::DefaultContextMenu);
header()->setContextMenuPolicy(Qt::ActionsContextMenu);
QAction *showSearchBox = new QAction(tr("Show Search Box"), this);
showSearchBox->setShortcut( Qt::CTRL + Qt::Key_F);
showSearchBox->setShortcutContext(Qt::ApplicationShortcut);
addAction(showSearchBox);
searchBox->installEventFilter(this);
searchBox->hide();
connect(showSearchBox, SIGNAL(triggered(bool)), this, SLOT(showSearchEdit()));
connect(searchBox, SIGNAL(textChanged(QString)), model, SLOT(setFilterFixedString(QString)));
selectedTrips.clear();
}
示例3: KDialog
CopyInputDialog::CopyInputDialog(QWidget* parent)
: KDialog(parent)
{
setCaption(i18n("Copy Input"));
setButtons(KDialog::Ok | KDialog::Cancel);
setWindowModality(Qt::WindowModal);
_ui = new Ui::CopyInputDialog();
_ui->setupUi(mainWidget());
connect(_ui->selectAllButton, SIGNAL(clicked()), this, SLOT(selectAll()));
connect(_ui->deselectAllButton, SIGNAL(clicked()), this, SLOT(deselectAll()));
_ui->filterEdit->setClearButtonShown(true);
_ui->filterEdit->setFocus();
_model = new CheckableSessionModel(parent);
_model->setCheckColumn(1);
_model->setSessions(SessionManager::instance()->sessions());
QSortFilterProxyModel* filterProxyModel = new QSortFilterProxyModel(this);
filterProxyModel->setDynamicSortFilter(true);
filterProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
filterProxyModel->setSourceModel(_model);
filterProxyModel->setFilterKeyColumn(-1);
connect(_ui->filterEdit, SIGNAL(textChanged(QString)),
filterProxyModel, SLOT(setFilterFixedString(QString)));
_ui->sessionList->setModel(filterProxyModel);
_ui->sessionList->setColumnHidden(0, true); // Hide number column
_ui->sessionList->header()->hide();
}
示例4: main
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QFrame frame;
QVBoxLayout verticalLayout;
QLineEdit filterText;
ProblemsTableModel submissions;
// add data here
QSortFilterProxyModel proxy;
proxy.setSortCaseSensitivity(Qt::CaseInsensitive);
proxy.setFilterCaseSensitivity(Qt::CaseInsensitive);
proxy.setSourceModel(&submissions);
// sort and filter by "Full name" column
proxy.setFilterKeyColumn(2);
QTableView tableView;
tableView.setModel(&proxy);
tableView.setSortingEnabled(true);
verticalLayout.addWidget(&filterText);
verticalLayout.addWidget(&tableView);
frame.setLayout(&verticalLayout);
QObject::connect(&filterText, &QLineEdit::textChanged, &proxy, &QSortFilterProxyModel::setFilterFixedString);
frame.show();
return app.exec();
}
示例5: QFrame
CaptureDialog::CaptureDialog(CaptureContext *ctx, OnCaptureMethod captureCallback,
OnInjectMethod injectCallback, QWidget *parent)
: QFrame(parent), ui(new Ui::CaptureDialog), m_Ctx(ctx)
{
ui->setupUi(this);
// setup FlowLayout for options group
{
QLayout *oldLayout = ui->optionsGroup->layout();
QObjectList options = ui->optionsGroup->children();
options.removeOne((QObject *)oldLayout);
delete oldLayout;
FlowLayout *optionsFlow = new FlowLayout(ui->optionsGroup, -1, 3, 3);
optionsFlow->setFixedGrid(true);
for(QObject *o : options)
optionsFlow->addWidget(qobject_cast<QWidget *>(o));
ui->optionsGroup->setLayout(optionsFlow);
}
ui->envVar->setEnabled(false);
m_ProcessModel = new QStandardItemModel(0, 3, this);
m_ProcessModel->setHeaderData(0, Qt::Horizontal, tr("Name"));
m_ProcessModel->setHeaderData(1, Qt::Horizontal, tr("PID"));
m_ProcessModel->setHeaderData(2, Qt::Horizontal, tr("Window Title"));
QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this);
proxy->setSourceModel(m_ProcessModel);
// filter on all columns
proxy->setFilterKeyColumn(-1);
// allow updating the underlying model
proxy->setDynamicSortFilter(true);
ui->processList->setModel(proxy);
ui->processList->setAlternatingRowColors(true);
// sort by PID by default
ui->processList->sortByColumn(1, Qt::AscendingOrder);
// TODO Vulkan Layer
ui->vulkanLayerWarn->setVisible(false);
m_CaptureCallback = captureCallback;
m_InjectCallback = injectCallback;
setSettings(CaptureSettings());
updateGlobalHook();
}
示例6: wrapInProxyModel
static QSortFilterProxyModel* wrapInProxyModel(QAbstractItemModel* model)
{
QSortFilterProxyModel* proxyModel = new QSortFilterProxyModel(model);
proxyModel->setSourceModel(model);
proxyModel->setDynamicSortFilter(true);
proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive);
proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
proxyModel->setFilterKeyColumn(-1);
return proxyModel;
}
示例7: QWidget
CMessageDock::CMessageDock(QWidget *parent)
: QWidget(parent)
, m_countOfErrorMessages(0)
, m_countOfWarningMessages(0)
, m_countOfInfomationMessages(0)
{
QVBoxLayout* layout = new QVBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0);
layout->setSpacing(0);
layout->addWidget(m_toolBar = new QToolBar(this));
layout->addWidget(m_listWidget = new QTreeView(this));
QStandardItemModel* model = new QStandardItemModel();
QSortFilterProxyModel* proxyModel = new QSortFilterProxyModel();
proxyModel->setSourceModel(model);
proxyModel->setDynamicSortFilter(true);
proxyModel->setFilterKeyColumn(CategoryColumn);
m_listWidget->setRootIsDecorated(false);
m_listWidget->setSortingEnabled(true);
m_listWidget->setModel(proxyModel);
m_listWidget->setEditTriggers(QTreeView::NoEditTriggers);
m_listWidget->setIndentation(0);
m_listWidget->setAlternatingRowColors(true);
model->invisibleRootItem()->insertColumns(0, ColumnCount);
model->setHeaderData(CategoryColumn, Qt::Horizontal, tr("Category"));
model->setHeaderData(FileNameColumn, Qt::Horizontal, tr("File"));
model->setHeaderData(LineNoColumn, Qt::Horizontal, tr("Line"));
model->setHeaderData(DescriptionColumn, Qt::Horizontal, tr("Description"));
m_listWidget->setColumnWidth(CategoryColumn, 16 + 10/*何の値だろう?*/);
m_listWidget->setColumnWidth(FileNameColumn, m_listWidget->fontMetrics().width(QLatin1Char('9')) * 20);
m_listWidget->setColumnWidth(LineNoColumn, m_listWidget->fontMetrics().width(QLatin1Char('9')) * 5);
connect(m_listWidget, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(doubleClickedList(const QModelIndex &)));
m_toolBar->setStyleSheet("QToolBar{border:none}");
m_toolBar->setIconSize(QSize(16, 16));
m_toolBar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
m_visibledErrorAction = m_toolBar->addAction(QIcon(":/images/tango/small/dialog-error.png"), "");
m_toolBar->addSeparator();
m_visibledWarningAction = m_toolBar->addAction(QIcon(":/images/icons/small/software-update-urgent-yellow.png"), "");
m_toolBar->addSeparator();
m_visibledInfomationAction = m_toolBar->addAction(QIcon(":/images/tango/small/dialog-information.png"), "");
m_visibledErrorAction->setCheckable(true);
m_visibledErrorAction->setChecked(true);
m_visibledWarningAction->setCheckable(true);
m_visibledWarningAction->setChecked(true);
m_visibledInfomationAction->setCheckable(true);
m_visibledInfomationAction->setChecked(true);
connect(m_visibledErrorAction, SIGNAL(triggered()), this, SLOT(onUpdateCategoryVisibled()));
connect(m_visibledWarningAction, SIGNAL(triggered()), this, SLOT(onUpdateCategoryVisibled()));
connect(m_visibledInfomationAction, SIGNAL(triggered()), this, SLOT(onUpdateCategoryVisibled()));
updateMessagesCount();
}
示例8: Widget
Widget() {
m_layout.addWidget(&m_view, 0, 0, 1, 1);
m_layout.addWidget(&m_button, 1, 0, 1, 1);
connect(&m_button, SIGNAL(clicked()), &m_dialog, SLOT(open()));
m_model.append({"Volvo", "240", "SQL8941"});
m_model.append({"Volvo", "850", {}});
m_model.append({"Volvo", "940", "QRZ1321"});
m_model.append({"Volvo", "960", "QRZ1628"});
m_proxy.setSourceModel(&m_model);
m_proxy.setFilterKeyColumn(2);
m_view.setModel(&m_proxy);
m_dialog.setLabelText("Enter registration number fragment to filter on. Leave empty to clear filter.");
m_dialog.setInputMode(QInputDialog::TextInput);
connect(&m_dialog, SIGNAL(textValueSelected(QString)),
&m_proxy, SLOT(setFilterFixedString(QString)));
}
示例9: main
int main(int argc, char** argv)
{
QApplication app(argc, argv);
QCommandLineParser parser;
parser.addPositionalArgument(QStringLiteral("filename"), QStringLiteral("file to visualize"));
parser.addHelpOption();
parser.process(app);
QStringList args = parser.positionalArguments();
if (args.size() != 1) {
parser.showHelp(1);
}
QWidget* mainWidget = new QWidget();
QVBoxLayout* layout = new QVBoxLayout(mainWidget);
mainWidget->setLayout(layout);
QLineEdit* edit = new QLineEdit();
layout->addWidget(edit);
QString fileName = args.first();
QTreeView* view = new QTreeView(0);
FunctionsModel* model = new FunctionsModel(view);
model->setFilePath(QFileInfo(fileName).absoluteFilePath());
QSortFilterProxyModel* sortModel = new QSortFilterProxyModel(view);
sortModel->setSourceModel(model);
sortModel->setFilterKeyColumn(2);
sortModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
view->setModel(sortModel);
view->setSortingEnabled(true);
layout->addWidget(view);
QObject::connect(edit, SIGNAL(textChanged(QString)),
sortModel, SLOT(setFilterFixedString(QString)));
mainWidget->show();
return app.exec();
}
示例10: QDialog
CopyInputDialog::CopyInputDialog(QWidget* parent)
: QDialog(parent)
{
setWindowTitle(i18n("Copy Input"));
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel);
QWidget *mainWidget = new QWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout;
setLayout(mainLayout);
mainLayout->addWidget(mainWidget);
QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
okButton->setDefault(true);
okButton->setShortcut(Qt::CTRL | Qt::Key_Return);
connect(buttonBox, &QDialogButtonBox::accepted, this, &CopyInputDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &CopyInputDialog::reject);
mainLayout->addWidget(buttonBox);
setWindowModality(Qt::WindowModal);
_ui = new Ui::CopyInputDialog();
_ui->setupUi(mainWidget);
connect(_ui->selectAllButton, &QPushButton::clicked, this, &Konsole::CopyInputDialog::selectAll);
connect(_ui->deselectAllButton, &QPushButton::clicked, this, &Konsole::CopyInputDialog::deselectAll);
_ui->filterEdit->setClearButtonEnabled(true);
_ui->filterEdit->setFocus();
_model = new CheckableSessionModel(parent);
_model->setCheckColumn(1);
_model->setSessions(SessionManager::instance()->sessions());
QSortFilterProxyModel* filterProxyModel = new QSortFilterProxyModel(this);
filterProxyModel->setDynamicSortFilter(true);
filterProxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive);
filterProxyModel->setSourceModel(_model);
filterProxyModel->setFilterKeyColumn(-1);
connect(_ui->filterEdit, &QLineEdit::textChanged, filterProxyModel, &QSortFilterProxyModel::setFilterFixedString);
_ui->sessionList->setModel(filterProxyModel);
_ui->sessionList->setColumnHidden(0, true); // Hide number column
_ui->sessionList->header()->hide();
}
示例11: QWidget
LogBrowser::LogBrowser(QWidget *parent)
: QWidget(parent)
, m_nextID(0)
, m_actorFilterActive(false)
, m_actorFilterCheck(0)
{
m_log = new LogModel(this);
m_log->setResultType(Log::MostRecentSubjects);
QSortFilterProxyModel *filter = new QSortFilterProxyModel(this);
filter->setSourceModel(m_log);
filter->setSortCaseSensitivity(Qt::CaseInsensitive);
filter->setDynamicSortFilter(true);
filter->setFilterKeyColumn(0);
QLineEdit *searchBox = new QLineEdit(this);
searchBox->setPlaceholderText(tr("Search"));
connect(searchBox, SIGNAL(textEdited(QString)), filter, SLOT(setFilterFixedString(QString)));
QListView *view = new QListView(this);
view->setResizeMode(QListView::Adjust);
connect(view, SIGNAL(activated(QModelIndex)), this, SLOT(handleActivation(QModelIndex)));
m_logView = view;
m_logView->setModel(filter);
QVBoxLayout *layout = new QVBoxLayout(this);
m_filterLayout = new QHBoxLayout(this);
layout->addWidget(searchBox);
layout->addLayout(m_filterLayout);
layout->addWidget(m_logView);
m_actionMapper = new QSignalMapper(this);
connect(m_actionMapper, SIGNAL(mapped(int)), this, SLOT(applyFilter(int)));
DataModel::Event emptyEvent;
addEventFilter(DataModel::EventList() << emptyEvent, "All")->setChecked(true);
}
示例12: 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);
}
示例13: QFrame
CaptureDialog::CaptureDialog(ICaptureContext &ctx, OnCaptureMethod captureCallback,
OnInjectMethod injectCallback, MainWindow *main, QWidget *parent)
: QFrame(parent), ui(new Ui::CaptureDialog), m_Ctx(ctx), m_Main(main)
{
ui->setupUi(this);
ui->exePath->setFont(Formatter::PreferredFont());
ui->workDirPath->setFont(Formatter::PreferredFont());
ui->cmdline->setFont(Formatter::PreferredFont());
ui->processList->setFont(Formatter::PreferredFont());
// setup FlowLayout for options group
{
QLayout *oldLayout = ui->optionsGroup->layout();
QObjectList options = ui->optionsGroup->children();
options.removeOne((QObject *)oldLayout);
delete oldLayout;
FlowLayout *optionsFlow = new FlowLayout(ui->optionsGroup, -1, 3, 3);
optionsFlow->setFixedGrid(true);
for(QObject *o : options)
optionsFlow->addWidget(qobject_cast<QWidget *>(o));
ui->optionsGroup->setLayout(optionsFlow);
}
ui->envVar->setEnabled(false);
m_ProcessModel = new QStandardItemModel(0, 3, this);
m_ProcessModel->setHeaderData(0, Qt::Horizontal, tr("Name"));
m_ProcessModel->setHeaderData(1, Qt::Horizontal, tr("PID"));
m_ProcessModel->setHeaderData(2, Qt::Horizontal, tr("Window Title"));
QSortFilterProxyModel *proxy = new QSortFilterProxyModel(this);
proxy->setSourceModel(m_ProcessModel);
// filter on all columns
proxy->setFilterKeyColumn(-1);
// allow updating the underlying model
proxy->setDynamicSortFilter(true);
// use case-insensitive filtering
proxy->setFilterCaseSensitivity(Qt::CaseInsensitive);
ui->processList->setModel(proxy);
ui->processList->setAlternatingRowColors(true);
// sort by PID by default
ui->processList->sortByColumn(1, Qt::AscendingOrder);
// Set up warning for host layer config
initWarning(ui->vulkanLayerWarn);
ui->vulkanLayerWarn->setVisible(RENDERDOC_NeedVulkanLayerRegistration(NULL, NULL, NULL));
QObject::connect(ui->vulkanLayerWarn, &RDLabel::clicked, this,
&CaptureDialog::vulkanLayerWarn_mouseClick);
// Set up scanning for Android apps
initWarning(ui->androidScan);
// Set up warning for Android apps
initWarning(ui->androidWarn);
QObject::connect(ui->androidWarn, &RDLabel::clicked, this, &CaptureDialog::androidWarn_mouseClick);
m_AndroidFlags = AndroidFlags::NoFlags;
m_CaptureCallback = captureCallback;
m_InjectCallback = injectCallback;
SetSettings(CaptureSettings());
UpdateGlobalHook();
}