本文整理汇总了C++中QListView::setRootIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ QListView::setRootIndex方法的具体用法?C++ QListView::setRootIndex怎么用?C++ QListView::setRootIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QListView
的用法示例。
在下文中一共展示了QListView::setRootIndex方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
// 创建文件系统模型
QFileSystemModel model;
// 指定要监视的目录
model.setRootPath(QDir::currentPath());
// 创建树型视图
QTreeView tree;
// 为视图指定模型
tree.setModel(&model);
// 指定根索引
tree.setRootIndex(model.index(QDir::currentPath()));
// 创建列表视图
QListView list;
list.setModel(&model);
list.setRootIndex(model.index(QDir::currentPath()));
tree.show();
list.show();
return app.exec();
}
示例2: main
//! [0] //! [1]
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QSplitter *splitter = new QSplitter;
//! [2] //! [3]
QDirModel *model = new QDirModel;
//! [0] //! [2] //! [4] //! [5]
QTreeView *tree = new QTreeView(splitter);
//! [3] //! [6]
tree->setModel(model);
//! [4] //! [6] //! [7]
tree->setRootIndex(model->index(QDir::currentPath()));
//! [7]
QListView *list = new QListView(splitter);
list->setModel(model);
list->setRootIndex(model->index(QDir::currentPath()));
//! [5]
QItemSelectionModel *selection = new QItemSelectionModel(model);
tree->setSelectionModel(selection);
list->setSelectionModel(selection);
//! [8]
splitter->setWindowTitle("Two views onto the same directory model");
splitter->show();
return app.exec();
}
示例3: QDialog
Rozmowa::Rozmowa(QWidget *parent, const QModelIndex& index, Model* mod ) :
QDialog(parent),
ui(new Ui::Rozmowa)
{
ui->setupUi(this);
message = this->findChild<QPlainTextEdit*>("wiadomosc");//message qplaintext wyslanie
message->insertPlainText("");
message->clear();
QPushButton* send = this->findChild<QPushButton*>("send");
model = mod;
QModelIndex ind = model->index( index.row(), 0, QModelIndex() );
//((MainWindow*)this->parent())->logged_user.numer;
QVariant value = model->data( ind, Qt::DisplayRole).toString();
QString title = value.toString();
ind = model->index( index.row(), 2 );
char numer[9];
itoa(((MainWindow*)this->parent())->logged_user.numer,numer,10);
title += " - (";
//title += ind.data().toString();
title += " moj numer: ";
title += numer;
title += ")";
setWindowTitle(title);
QListView* rozmowa = this->findChild<QListView*>("rozmowa");
rozmowa->setModel(model);
rozmowa->setRootIndex(index);
connect(send, SIGNAL(clicked()), ((MainWindow*)this->parent())->socket, SLOT(send_text_message()));
connect(this->model, SIGNAL(syg_rozm(int)),this,SLOT(syg_rozm_slot(int)));
}
示例4: 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();
}
示例5: exempleDirModel
void Window::exempleDirModel()
{
QVBoxLayout* layout = new QVBoxLayout;
QDirModel* modele = new QDirModel;
QTreeView* treeView = new QTreeView;
QListView* listView = new QListView;
treeView->setModel(modele);
listView->setModel(modele);
treeView->setRootIndex(modele->index("C:/MinGW"));
listView->setRootIndex(modele->index("C:"));
layout->addWidget(treeView);
setCentralWidget(treeView);
}
示例6: Test_FileSystem_MVC
void Test_FileSystem_MVC()
{
QSplitter* splitter = new QSplitter;//two widget
QFileSystemModel* model = new QFileSystemModel;
QTreeView* tree = new QTreeView(splitter);//left tree view
QListView* list = new QListView(splitter);//right list view
splitter->setWindowTitle("Two vies onto the same file system model");
model->setRootPath(QDir::currentPath());
tree->setModel(model);//set model for view
tree->setRootIndex(model->index(QDir::currentPath()));
list->setModel(model);
list->setRootIndex(model->index(QDir::currentPath()));
list->setSelectionModel(tree->selectionModel());
splitter->show();
}
示例7: main
int main(int argc, char *argv[]) {
QApplication app(argc, argv);
QSplitter splitter;
QTreeView *tree = new QTreeView(&splitter);
QListView *list = new QListView(&splitter);
QFileSystemModel *model = new QFileSystemModel(&app);
model->setRootPath(QDir::root().path());
tree->setModel(model);
list->setModel(model);
list->setRootIndex(model->index("."));
splitter.show();
return app.exec();
}