当前位置: 首页>>代码示例>>C++>>正文


C++ QTreeView::setExpanded方法代码示例

本文整理汇总了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;
}
开发者ID:Wushaowei001,项目名称:NAF,代码行数:7,代码来源:QtlTreeView.cpp

示例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 );
}
开发者ID:Wushaowei001,项目名称:NAF,代码行数:8,代码来源:TreeCtrl.cpp

示例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;
}
开发者ID:nnemkin,项目名称:perpetuum-planner,代码行数:12,代码来源:delegates.cpp

示例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);
	}
}
开发者ID:fredemmott,项目名称:jerboa,代码行数:79,代码来源:FileSystemTab.cpp


注:本文中的QTreeView::setExpanded方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。