本文整理汇总了C++中QListView::model方法的典型用法代码示例。如果您正苦于以下问题:C++ QListView::model方法的具体用法?C++ QListView::model怎么用?C++ QListView::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QListView
的用法示例。
在下文中一共展示了QListView::model方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: slotDeleteSelected
void VegetationWidget::slotDeleteSelected()
{
QListView* view = qobject_cast<QListView*>(sender());
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(view->model());
QString dirString("");
if (view == _treeListView)
{
std::string plantDir = g_SystemContext._workContextDir;
plantDir.append(CONTEXT_DIR);
plantDir.append("/Plant/");
dirString = chineseTextUTF8ToQString(plantDir + "Tree/");
}
else
{
std::string plantDir = g_SystemContext._workContextDir;
plantDir.append(CONTEXT_DIR);
plantDir.append("/Plant/");
dirString = chineseTextUTF8ToQString(plantDir + "Grass/");
}
QItemSelectionModel* selectionModel = view->selectionModel();
QModelIndexList modelList = selectionModel->selectedIndexes();
if (modelList.size() < 1)
return;
for (int i = 0; i < modelList.size(); ++i)
{
QStandardItem* everyItem = model->itemFromIndex(modelList.at(i));
QFile::remove(dirString + everyItem->text());
int row = everyItem->row();
model->removeRow(row);
}
}
示例2: setModel
/*!
Sets \a model to be the ThemeListModel associated with this ThemeListItem.
If this item currently has a QListView widget set, this model is installed
immediately on the view using QListView::setModel().
If a call is made to QWidget::setWidget() in the future, this model
will be installed in the same way.
*/
void QThemeListItem::setModel(QThemeListModel *model)
{
if (d->model != model) {
d->model = model;
QListView* view = listView();
if (view != 0 && view->model() != d->model)
view->setModel(d->model);
}
}
示例3: QCOMPARE
void tst_QFontDialog::task256466_wrongStyle()
{
QFontDatabase fdb;
FriendlyFontDialog dialog;
QListView *familyList = reinterpret_cast<QListView*>(dialog.d_func()->familyList);
QListView *styleList = reinterpret_cast<QListView*>(dialog.d_func()->styleList);
QListView *sizeList = reinterpret_cast<QListView*>(dialog.d_func()->sizeList);
for (int i = 0; i < familyList->model()->rowCount(); ++i) {
QModelIndex currentFamily = familyList->model()->index(i, 0);
familyList->setCurrentIndex(currentFamily);
const QFont current = dialog.currentFont(),
expected = fdb.font(currentFamily.data().toString(),
styleList->currentIndex().data().toString(), sizeList->currentIndex().data().toInt());
QCOMPARE(current.family(), expected.family());
QCOMPARE(current.style(), expected.style());
QCOMPARE(current.pointSizeF(), expected.pointSizeF());
}
}
示例4: slotViewSelected
void VegetationWidget::slotViewSelected()
{
QListView* view = qobject_cast<QListView*>(sender());
QItemSelectionModel* selectionModel = view->selectionModel();
QModelIndexList modelList = selectionModel->selectedIndexes();
if (modelList.size() < 1)
return;
QStandardItemModel* model = qobject_cast<QStandardItemModel*>(view->model());
std::string dirString("");
if (view == _treeListView)
{
std::string plantDir = g_SystemContext._workContextDir;
plantDir.append(CONTEXT_DIR);
plantDir.append("/Plant/");
dirString = plantDir + "Tree/";
}
else
{
std::string plantDir = g_SystemContext._workContextDir;
plantDir.append(CONTEXT_DIR);
plantDir.append("/Plant/");
dirString = plantDir + "Grass/";
}
QStandardItem* currentItem = model->itemFromIndex(modelList.at(0));
dirString.append(chineseTextToUTF8String(currentItem->text()));
osg::ref_ptr<osg::Node> node;
if (currentItem->text().endsWith(".osgb"))
{
node = g_SystemContext._resourceLoader->getNodeByName(dirString, false);
}
else
{
osg::ref_ptr<osg::Image> image = g_SystemContext._resourceLoader->getImageByFileName(dirString);
if (image.valid())
{
float s = image->s();
float t = image->t();
osg::ref_ptr<osg::Geometry> geometry = osg::createTexturedQuadGeometry(osg::Vec3(-s / 2.0f, -t / 2.0f, 0), osg::Vec3(s, 0, 0), osg::Vec3(0, t, 0));
osg::ref_ptr<osg::Geode> geode = new osg::Geode;
geode->addDrawable(geometry);
osg::StateSet* ss = geode->getOrCreateStateSet();
ss->setMode(GL_BLEND, osg::StateAttribute::ON);
ss->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
osg::Texture2D* texture = new osg::Texture2D(image);
ss->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
node = geode;
}
}
if (node.valid())
{
_nodeViewDialog = new NodeViewDialog;
_nodeViewDialog->setNode(node);
_nodeViewDialog->exec();
//_nodeViewDialog->setNode(NULL);
}
}
示例5: loadProjects
void MainWindow::loadProjects()
{
QListView *view = ui->centralWidget->findChild<QListView*>("projectLst");
QStandardItemModel *model = static_cast<QStandardItemModel*>(view->model());
QVector<Project*> projects = Project::getProjects();
foreach(Project *p, projects) {
QStandardItem *item = new QStandardItem();
item->setData(p->getName(), ProjectItemDelegate::nameTextRole);
model->appendRow(item);
}
示例6: processResults
/** Process results sent back from various search engines (local, remote). */
void SearchDialog::processResults(Request type, const QStandardItemList &results)
{
QListView *listToProcess = nullptr;
switch (type) {
case Artist:
listToProcess = _artists;
break;
case Album:
listToProcess = _albums;
break;
case Track:
listToProcess = _tracks;
break;
}
QStandardItemModel *m = qobject_cast<QStandardItemModel*>(listToProcess->model());
for (int i = 0; i < results.size(); i++) {
m->insertRow(0, results.at(i));
}
m->sort(0);
listToProcess->setFixedHeight(listToProcess->model()->rowCount() * listToProcess->sizeHintForRow(0));
qDebug() << "number of items" << listToProcess->model()->rowCount();
qDebug() << "size h f r 1" << _artists->sizeHintForRow(0) << _albums->sizeHintForRow(0) << _tracks->sizeHintForRow(0);
qDebug() << "size h f r 2" << iconArtists->height() << iconAlbums->height() << iconTracks->height();
int ar = qMax(_artists->model()->rowCount() * _artists->sizeHintForRow(0), iconArtists->height());
int al = qMax(_albums->model()->rowCount() * _albums->sizeHintForRow(0), iconAlbums->height());
int tr = qMax(_tracks->model()->rowCount() * _tracks->sizeHintForRow(0), iconTracks->height());
artistLayoutWidget->setFixedHeight(ar);
albumLayoutWidget->setFixedHeight(al);
trackLayoutWidget->setFixedHeight(tr);
qDebug() << "ar al tr" << ar << al << tr;
int h = ar + al + tr;
//int h = 300;
h += labelSearchMore->height() + aggregated->height() + 3;
int minW = qMax(iconArtists->width() + _artists->sizeHintForColumn(0), 400);
this->resize(minW, h);
}
示例7: on_deleteButton_clicked
void MessagePage::on_deleteButton_clicked()
{
QListView *list = ui->listConversation;
if(!list->selectionModel())
return;
QModelIndexList indexes = list->selectionModel()->selectedIndexes();
if(!indexes.isEmpty())
{
list->model()->removeRow(indexes.at(0).row());
indexes = list->selectionModel()->selectedIndexes();
if(indexes.isEmpty())
on_backButton_clicked();
}
}
示例8:
/**
* @brief MainWindow::setDocumentModel
*
* Will be called whe a new q2d::Project is created, to link the projects
* document model with the appropriate list view in the UI.
* @param model
*/
void
MainWindow::slot_setDocumentModel(QStandardItemModel* model) {
// close all tabs related to the old model
m_ui->schematicsTabWidget->clear();
QListView* documentView = m_ui->documentListView;
documentView->clearSelection();
QAbstractItemModel* oldModel = documentView->model();
m_ui->documentListView->setModel(model);
if (oldModel != nullptr) {
oldModel->disconnect();
oldModel->deleteLater();
}
}
示例9: findListView
QStringListModel * GraphicalArrayTest::findModel(const GraphicalArray* value)
{
// /!\ WARNING /!\
// THE FOLLOWING CODE IS EXTREMELY SENSITIVE TO ANY MODIFICATION
// OF THE GRAPHICAL LOOK OF GraphicalArray
QListView * view = findListView(value);
QStringListModel * model = nullptr;
if( is_not_null(view) )
{
model = dynamic_cast<QStringListModel*>( view->model() );
if( is_null(model) )
QWARN("Failed to find the view model.");
}
return model;
}
示例10: deleteSelected
void EmoticonViewer::deleteSelected()
{
QListView *view = _ui->listView;
view->model()->removeRow(view->currentIndex().row());
}
示例11: accept
void EmoticonViewer::accept()
{
QListView *view = _ui->listView;
emit hasTextToInsert(view->model()->data(view->currentIndex()).toString());
close();
}