2011-05-26 76 views
4

通过使用QFileSystemModel很容易实现文件浏览器。但是,ListView UI并不漂亮。所以我想用QML实现一个文件浏览器。 QML具有模型/视图支持。但是如何在QML中显示文件系统树?任何线索将不胜感激。基于QML的Qt文件浏览器

回答

1

我认为它的晚了,但它仍然可以帮助一些。

我最近为使用Qt Quick Components的Symbian项目创建了基于QML的filedialog。它的实施是here

而且here is sample application

4

由于Qt5.5我们可用TreeView QML组件,

main.qml

import QtQuick.Controls 1.4 
TreeView { 
    anchors.fill: parent 
    TableViewColumn { 
     title: "Name" 
     role: "fileName" 
     width: 300 
    } 
    model: my_model 
} 

main.cpp

QFileSystemModel model; 
model.setRootPath("/"); 
QQmlApplicationEngine engine; 
engine.rootContext()->setContextProperty("my_model", &model); 
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));