本文整理汇总了C++中QTreeView::setCurrentIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeView::setCurrentIndex方法的具体用法?C++ QTreeView::setCurrentIndex怎么用?C++ QTreeView::setCurrentIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeView
的用法示例。
在下文中一共展示了QTreeView::setCurrentIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reloadFolders
void BookmarkPropertiesDialog::reloadFolders()
{
m_model->clear();
QStandardItem *item = new QStandardItem(Utils::getIcon(QLatin1String("inode-directory")), tr("Bookmarks"));
item->setData(0, Qt::UserRole);
item->setToolTip(tr("Bookmarks"));
m_model->invisibleRootItem()->appendRow(item);
m_index = item->index();
populateFolder(BookmarksManager::getFolder(0), item);
QTreeView *view = qobject_cast<QTreeView*>(m_ui->folderComboBox->view());
if (view)
{
view->setCurrentIndex(m_index);
view->expandAll();
m_ui->folderComboBox->setRootModelIndex(m_index.parent());
m_ui->folderComboBox->setModelColumn(0);
m_ui->folderComboBox->setCurrentIndex(m_index.row());
m_ui->folderComboBox->setRootModelIndex(QModelIndex());
}
}
示例2: QDialog
AddBookmarkDialog::AddBookmarkDialog(const QString &url, const QString &title, QWidget *parent, BookmarksManager *bookmarkManager)
: QDialog(parent)
, m_url(url)
, m_bookmarksManager(bookmarkManager)
{
setWindowFlags(Qt::Sheet);
if (!m_bookmarksManager)
m_bookmarksManager = BrowserApplication::bookmarksManager();
setupUi(this);
QTreeView *view = new QTreeView(this);
m_proxyModel = new AddBookmarkProxyModel(this);
BookmarksModel *model = m_bookmarksManager->bookmarksModel();
m_proxyModel->setSourceModel(model);
view->setModel(m_proxyModel);
view->expandAll();
view->header()->setStretchLastSection(true);
view->header()->hide();
view->setItemsExpandable(false);
view->setRootIsDecorated(false);
view->setIndentation(10);
location->setModel(m_proxyModel);
view->show();
location->setView(view);
BookmarkNode *menu = m_bookmarksManager->menu();
QModelIndex idx = m_proxyModel->mapFromSource(model->index(menu));
view->setCurrentIndex(idx);
location->setCurrentIndex(idx.row());
name->setText(title);
}