Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt File Browser based on QML

It is easy to implement a file browser by using QFileSystemModel. But the listview UI is not pretty. So I want to implement a file browser using QML. the QML has model/view support. But how to display the filesystem tree in QML? Any clue would be appreciated.

like image 900
catinred Avatar asked May 26 '11 03:05

catinred


2 Answers

Since Qt5.5 we have TreeView QML component available,

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")));
like image 70
Libor Tomsik Avatar answered Sep 16 '22 21:09

Libor Tomsik


I think its kind of late, but still it might help some one.

I recently created QML based filedialog for my project for Symbian using Qt Quick Components. Its implementation is here,

And here is sample application,

like image 40
Kunal Avatar answered Sep 16 '22 21:09

Kunal