本文整理汇总了C++中QTreeView::setDragDropMode方法的典型用法代码示例。如果您正苦于以下问题:C++ QTreeView::setDragDropMode方法的具体用法?C++ QTreeView::setDragDropMode怎么用?C++ QTreeView::setDragDropMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTreeView
的用法示例。
在下文中一共展示了QTreeView::setDragDropMode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildFileBrowser
void MainWindow::buildFileBrowser()
{
QString rootPath = qgetenv("HOME");
this->drivesModel->setFilter(QDir::NoDotAndDotDot | QDir::Dirs);
QTreeView *treeView = this->treeView = new QTreeView(this->ui->dockDir);
treeView->setModel(this->drivesModel);
treeView->setRootIndex(this->drivesModel->setRootPath(rootPath + "/../"));
treeView->hideColumn(1);
treeView->hideColumn(2);
treeView->hideColumn(3);
treeView->setEditTriggers(QAbstractItemView::NoEditTriggers);
treeView->setDragEnabled(true);
treeView->setDragDropMode(QAbstractItemView::DragOnly);
this->ui->dockDir->setWidget(treeView);
this->filesModel->setFilter(QDir::NoDotAndDotDot | QDir::Files);
QListView *listView = this->listView = new QListView(this->ui->dockFile);
listView->setModel(this->filesModel);
listView->setRootIndex(this->filesModel->setRootPath(rootPath));
listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
listView->setDragEnabled(true);
listView->setSelectionMode(QAbstractItemView::ExtendedSelection);
this->ui->dockFile->setWidget(listView);
listView->show();
treeView->show();
}
示例2: 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);
}
}