#include <QtGui>
int main(int argc, char *argv[])
{
// a "file manager" at simplest :)
tree->setModel(model);
list->setModel(model);
list->setDragEnabled(true);
splitter->show();
// tree navigation by click
QObject::connect(tree,
SIGNAL(clicked
(const QModelIndex
&)),
list, SLOT(setRootIndex(const QModelIndex&)));
// list navigation by dbl click
QObject::connect(list,
SIGNAL(doubleClicked
(const QModelIndex
&)),
list, SLOT(setRootIndex(const QModelIndex&)));
// update tree upon list change
QObject::connect(list,
SIGNAL(doubleClicked
(const QModelIndex
&)),
tree, SLOT(setCurrentIndex(const QModelIndex&)));
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// a "file manager" at simplest :)
QSplitter* splitter = new QSplitter;
QDirModel* model = new QDirModel;
QTreeView* tree = new QTreeView(splitter);
tree->setModel(model);
QListView* list = new QListView(splitter);
list->setModel(model);
list->setDragEnabled(true);
splitter->show();
// tree navigation by click
QObject::connect(tree, SIGNAL(clicked(const QModelIndex&)),
list, SLOT(setRootIndex(const QModelIndex&)));
// list navigation by dbl click
QObject::connect(list, SIGNAL(doubleClicked(const QModelIndex&)),
list, SLOT(setRootIndex(const QModelIndex&)));
// update tree upon list change
QObject::connect(list, SIGNAL(doubleClicked(const QModelIndex&)),
tree, SLOT(setCurrentIndex(const QModelIndex&)));
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks