以下代碼在windows xp + Qt4.7.1下OK.
[code/]
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QFileSystemModel model;
model.setRootPath("");
QTreeView tree;
tree.setModel(&model);
tree.setCurrentIndex(model.index(0,0,model.index(0,0,model.index(QDir::currentPath()))));
tree.setWindowTitle(QObject::tr("Dir View"));
tree.resize(640, 480);
tree.show();
return app.exec();
}
[/code]