本文整理汇总了C++中QListWidget::model方法的典型用法代码示例。如果您正苦于以下问题:C++ QListWidget::model方法的具体用法?C++ QListWidget::model怎么用?C++ QListWidget::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QListWidget
的用法示例。
在下文中一共展示了QListWidget::model方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: selectItem
bool ThemeManager::selectItem(const QString& id, bool is_default)
{
QListWidget* view = m_themes;
QListWidget* other_view = m_default_themes;
if (is_default) {
std::swap(view, other_view);
}
QAbstractItemModel* model = view->model();
QModelIndexList items = model->match(model->index(0, 0, QModelIndex()),
Qt::UserRole, id, 1, Qt::MatchFixedString | Qt::MatchCaseSensitive);
if (!items.isEmpty()) {
view->setCurrentRow(items.first().row());
other_view->setCurrentIndex(other_view->rootIndex());
m_tabs->setCurrentIndex(!is_default);
return true;
} else {
return false;
}
}
示例2: QStringListModel
/*!
Return a new modelType.
*/
QAbstractItemModel *ModelsToTest::createModel(const QString &modelType)
{
if (modelType == "QStringListModelEmpty")
return new QStringListModel();
if (modelType == "QStringListModel") {
QStringListModel *model = new QStringListModel();
populateTestArea(model);
return model;
}
if (modelType == "QStandardItemModelEmpty") {
return new QStandardItemModel();
}
if (modelType == "QStandardItemModel") {
QStandardItemModel *model = new QStandardItemModel();
populateTestArea(model);
return model;
}
if (modelType == "QSortFilterProxyModelEmpty") {
QSortFilterProxyModel *model = new QSortFilterProxyModel;
QStandardItemModel *standardItemModel = new QStandardItemModel;
model->setSourceModel(standardItemModel);
return model;
}
if (modelType == "QSortFilterProxyModelRegExp") {
QSortFilterProxyModel *model = new QSortFilterProxyModel;
QStandardItemModel *standardItemModel = new QStandardItemModel;
model->setSourceModel(standardItemModel);
populateTestArea(model);
model->setFilterRegExp(QRegExp("(^$|0.*)"));
return model;
}
if (modelType == "QSortFilterProxyModel") {
QSortFilterProxyModel *model = new QSortFilterProxyModel;
QStandardItemModel *standardItemModel = new QStandardItemModel;
model->setSourceModel(standardItemModel);
populateTestArea(model);
return model;
}
if (modelType == "QDirModel") {
QDirModel *model = new QDirModel();
model->setReadOnly(false);
return model;
}
if (modelType == "QSqlQueryModel") {
QSqlQueryModel *model = new QSqlQueryModel();
populateTestArea(model);
return model;
}
if (modelType == "QSqlQueryModelEmpty") {
QSqlQueryModel *model = new QSqlQueryModel();
return model;
}
if (modelType == "QSqlTableModel") {
QSqlTableModel *model = new QSqlTableModel();
populateTestArea(model);
return model;
}
if (modelType == "QListModelEmpty")
return (new QListWidget)->model();
if (modelType == "QListModel") {
QListWidget *widget = new QListWidget;
populateTestArea(widget->model());
return widget->model();
}
if (modelType == "QTableModelEmpty")
return (new QTableWidget)->model();
if (modelType == "QTableModel") {
QTableWidget *widget = new QTableWidget;
populateTestArea(widget->model());
return widget->model();
}
if (modelType == "QTreeModelEmpty") {
QTreeWidget *widget = new QTreeWidget;
return widget->model();
}
if (modelType == "QTreeModel") {
QTreeWidget *widget = new QTreeWidget;
populateTestArea(widget->model());
return widget->model();
}
//.........这里部分代码省略.........