QDirModel *model = new QDirModel;QTreeView *tree = new QTreeView;QListView *list = new QListView;tree->setModel( model );list->setModel( model );connect( tree, SIGNAL( clicked( const QModelIndex & ) ), list, SLOT( setRootIndex( const QModelIndex & ) ) );
QDirModel *model = new QDirModel;proxyModel = new QSortFilterProxyModel;proxyModel->setDynamicSortFilter(true);proxyModel->setSourceModel(model);ui.listView->setModel(proxyModel); ui.treeView->setModel(model);connect( ui.treeView, SIGNAL( clicked( const QModelIndex & ) ), ui.listView, SLOT( setRootIndex( const QModelIndex & ) ) );
...connect( ui.treeView, SIGNAL( clicked( const QModelIndex & ) ), ui.listView, SLOT( setRootIndex( const QModelIndex & ) ) );
treeModel = new QDirModel; treeModel->setFilter( QDir::AllDirs | QDir::NoDotAndDotDot ); ui.treeView->setModel( treeModel ); ui.treeView->setColumnHidden( 1, true ); ui.treeView->setColumnHidden( 2, true ); ui.treeView->setColumnHidden( 3, true ); listModel = new QDirModel; ui.listView->setModel( listModel );void File::setRootIndex( const QModelIndex & index ) { QString path = treeModel->filePath( index ); ui.listView->setRootIndex( listModel->index( path ) ); }