13.2.1.  QFileSystemModel

[ fromfile: qtmodelview.xml id: filesystemmodel ]

Figure 13.5.  QFileSystemModel in a QTreeView

QFileSystemModel in a QTreeView

Example 13.1. src/modelview/filesystem/main.cpp

#include <QtGui>
int main(int argc, char *argv[]) {
    QApplication app(argc, argv);
    QFileSystemModel model;                
    model.setRootPath("/");           
    QTreeView tree;
    tree.setModel(&model);                 
    tree.setSortingEnabled(true);    1
    tree.header()->setResizeMode(QHeaderView::ResizeToContents);
    tree.resize(640, 480);
    tree.show();   
    return app.exec();
}

1

Enable HeaderView sort buttons.