Nitin Jain
Nitin Jain

Reputation: 289

Treeview for FileSystem with checkboxes in qt

We need a tree view with File system and check boxes in QT. Is there any way to achieve that?

The tree we need would look something like below:

enter image description here

UPDATE:

I am able to achieve it with subclass of QFileSystemModel. Still have few challenges, but at least subclass is working. Below is the code if anyone needs it. Below is the link to the code -

https://drive.google.com/file/d/1qViZ3iEW2pV2th0jQhzneDL14SEhIgS0/view?usp=sharing

The pending work is to apply a wait cursor (or make treeview uneditable when the check/uncheck is taking place).

PS: It will take a lot of time if root node is checked.

Upvotes: 3

Views: 2235

Answers (1)

MasterAler
MasterAler

Reputation: 1653

Well, all of that can be achieved with minimal customizations of built-in classes, actually those checkboxes is almost the only thing that has to be done yourself.

  • QFileSystemModel already provides a proper model for displaying the current filesystem contents, it can be subclassed
  • As for QML, the best demo is already provided by Qt, check the File System Browser Example. This example uses some deprecaded Qt functionality, but still it shows the basic concept.
  • The modern techniqes can be also found in the answers to the following question: Qt File Browser based on QML

Hopefully, all that helps you, good luck!

Upvotes: 2

Related Questions