本文整理汇总了C++中QStringListModel::setSourceModel方法的典型用法代码示例。如果您正苦于以下问题:C++ QStringListModel::setSourceModel方法的具体用法?C++ QStringListModel::setSourceModel怎么用?C++ QStringListModel::setSourceModel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QStringListModel
的用法示例。
在下文中一共展示了QStringListModel::setSourceModel方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
//.........这里部分代码省略.........