本文整理汇总了C++中QTreeView::setExpanded方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeView::setExpanded方法的具体用法?C++ QTreeView::setExpanded怎么用?C++ QTreeView::setExpanded使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeView
的用法示例。
在下文中一共展示了QTreeView::setExpanded方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setExpanded
int TreeView::setExpanded(lua_State * L) // ( const QModelIndex & index, bool expanded )
{
QTreeView* obj = QtObject<QTreeView>::check( L, 1);
QModelIndex* index = QtValue<QModelIndex>::check( L, 2 );
obj->setExpanded( *index, Util::toBool( L, 3 ) );
return 0;
}
示例2: handleExpand
void TreeCtrl::handleExpand(Root::Action & t)
{
QTreeView* tv = wnd();
QModelIndex i = tv->currentIndex();
ENABLED_IF( t, i.isValid() && ! tv->isExpanded( i ) );
tv->setExpanded( i, true );
}
示例3: editorEvent
bool RichTextDelegate::editorEvent(QEvent *event, QAbstractItemModel *model, const QStyleOptionViewItem &option, const QModelIndex &index)
{
if (event->type() == QEvent::MouseButtonPress) {
QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
if (mouseEvent->button() == Qt::LeftButton && mouseEvent->x() - option.rect.left() < 18 && model->hasChildren(index)) {
QTreeView *tree = static_cast<QTreeView *>(parent());
tree->setExpanded(index, !tree->isExpanded(index));
return true;
}
}
return false;
}
示例4: component
QObject* FileSystemTab::component(Jerboa::Plugin::ComponentType type, QObject* parent)
{
switch(type)
{
case Jerboa::Plugin::WidgetUsedWithPlaylist:
{
QFileSystemModel* model = new FileSystemModelWithToolTip(parent);
model->setRootPath("/");
model->setFilter(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::AllDirs);
model->setNameFilterDisables(false);
QStringList musicGlobs;
musicGlobs
<< "*.aac"
<< "*.aiff"
<< "*.ape"
<< "*.au"
<< "*.cdda"
<< "*.flac"
<< "*.m4a"
<< "*.mp3"
<< "*.oga"
<< "*.ogg"
<< "*.ogm"
<< "*.wav"
<< "*.wma"
;
model->setNameFilters(musicGlobs);
QTreeView* view = new QTreeView(qobject_cast<QWidget*>(parent));
view->setWindowTitle("Files");
view->setModel(model);
view->setHeaderHidden(true);
for(int i = 1; i < model->columnCount(); ++i)
{
view->setColumnHidden(i, true);
}
QString path = QDesktopServices::storageLocation(QDesktopServices::MusicLocation);
if(path.isEmpty() || !QDir(path).exists())
{
path = QDesktopServices::storageLocation(QDesktopServices::HomeLocation);
}
const QModelIndex index(model->index(QSettings().value("collection/directory", path).toString()));
for(QModelIndex iterator(index); iterator.isValid(); iterator = iterator.parent())
{
view->setExpanded(iterator, true);
}
view->setDragDropMode(QAbstractItemView::DragOnly);
view->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect);
view->setSelectionMode(QAbstractItemView::ExtendedSelection);
connect(
view,
SIGNAL(doubleClicked(QModelIndex)),
this,
SLOT(addPathToPlaylist(QModelIndex))
);
QTimer* timer = new QTimer(this);
connect(
timer,
SIGNAL(timeout()),
this,
SLOT(scrollToSelection())
);
timer->setSingleShot(true);
timer->start(1000);
m_view = view;
return view;
}
default:
return Jerboa::Plugin::component(type, parent);
}
}