2011-05-26 144 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")));