本文整理汇总了C++中QTreeView::expand方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeView::expand方法的具体用法?C++ QTreeView::expand怎么用?C++ QTreeView::expand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeView
的用法示例。
在下文中一共展示了QTreeView::expand方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadPlaylists
void MainWindow::loadPlaylists()
{
QTreeView *playlists = (QTreeView*)ui->tvPlaylists;
QStandardItemModel *model = new QStandardItemModel(3,1);
QStandardItem *item = new QStandardItem(QString(tr("Search")));
item->setData(DATA_SEARCH, DATA_KEY_PLAYLIST);
item->setEditable(false);
model->setItem(0, 0, item);
item = new QStandardItem(QString(tr("History")));
item->setData(DATA_HISTORY, DATA_KEY_PLAYLIST);
item->setEditable(false);
model->setItem(1, 0, item);
item = new QStandardItem(QString(tr("Playlists")));
item->setData(DATA_EMPTY, DATA_KEY_PLAYLIST);
item->setEditable(false);
QList<Playlist> pls = dp->getPlaylists();
int n = pls.count();
for( int i=0; i<n; i++ )
{
QStandardItem *child = new QStandardItem(pls[i].title);
child->setData(pls[i].id, DATA_KEY_PLAYLIST);
child->setEditable(false);
item->appendRow(child);
}
model->setItem(2, 0, item);
model->setHorizontalHeaderItem( 0, new QStandardItem(tr("Library")));
model->horizontalHeaderItem(0)->setEditable(false);
model->horizontalHeaderItem(0)->setEnabled(false);
playlists->setModel(model);
playlists->setContextMenuPolicy(Qt::CustomContextMenu);
QModelIndexList indexes = model->match(model->index(2,0), Qt::DisplayRole, "*", -1, Qt::MatchWildcard|Qt::MatchRecursive);
playlists->expand(indexes[0]);
connect(playlists->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), this, SLOT(loadPlaylist()));
}