Writing a file manager in QML

2019-09-13 03:17发布

I just started learning QML, with no previous experience in Qt or GUI development in general. My first task is to write a file manager. So far what I like about QML is that I can do design in plain text, but it's been quite challenging finding the way around to achieve even simple things. Currently I use Qt.labs.FolderListModel 2.1 as the work horse for directory listing, and I haven't even touched C++ or PyQt yet, it's purely QML now.

So I have a few questions regarding the future path of my little file manager:

  1. Is FolderListModel powerful enough to do all the things a versatile file manager can do? As far as I see, QFileSystemModel looks more feature complete? And the fact that the former is in Qt.labs worries me a bit. If indeed FolderListModel is meant to be used as a "quick-and-dirty" thing, does that mean that it's better to switch to QFileSystemModel sooner? Since I approached the Qt world from QML rather than the traditional C++ angle, what is it like to replace my current FolderListModel code in QML to something backed by Qt/C++ or PyQt?
  2. Related: I heard that it's actually possible to write complete applications in pure QML (with JavaScript). If the application is driven by some back-end, e.g. a database, I can see that QML alone is probably not expressive enough. However, in my case of writing a file manager, despite the "performance" argument, is it a good idea to try to stick to pure QML, using JavaScript for all the business logic?

1条回答
闹够了就滚
2楼-- · 2019-09-13 04:07

I have been working recently on a simple file manager in QML. The problems you will face if you stick only to QML are:

  • not being able to know how many drives are currently plugged in.
  • not being able to easily sort files by name. Using provided sorting flags will result in having B.txt before a.txt because of the case.

Fortunately it is easy to connect C++ classes with QML so you will always be able to expand default QML features.

How to connect C++ and QML: http://doc.qt.io/qt-5/qtqml-cppintegration-topic.html

查看更多
登录 后发表回答