0

I want to create a customized widget which can show files in every drive in system. Here is the layout:

Every row of QListView contains a title bar (QLabel) and a QListWidget which contains many icon to represent files.

I know how to use QItemDelegate to customize the looking of QListView, but I don't know how to create such a complex widget.

Does anyone can help me? Thank you very much for reading this post.

Bruce Hsu
  • 43
  • 6

1 Answers1

0

I think the QFileSystemModel is pretty close to the end solution you are looking for:

http://qt-project.org/doc/qt-5/QFileSystemModel.html#details

model = new QFileSystemModel();
QModelIndex mindex = model->setRootPath(QDir::homePath());
QTreeView * tree = ui->treeView;
tree->setModel(model);
tree->setRootIndex(mindex);

// Demonstrating look and feel features
tree->setAnimated(true);
tree->setIndentation(20);
tree->setSortingEnabled(true);
tree->setAlternatingRowColors(true);

There is also a built in example in Qt for a complex XML view of a file tree.

http://qt-project.org/doc/qt-5.0/qtxmlpatterns/xmlpatterns-filetree.html

As far as advanced examples using Model/Delegate programming, here are the resources I could find:

http://qt-project.org/doc/qt-5/model-view-programming.html

http://qt-project.org/doc/qt-5/model-view-programming.html#related-examples

Other places for code snippets are in the detailed info for the abstract classes that use model and delegate classes. For example:

http://qt-project.org/doc/qt-5/qabstractitemdelegate.html#details

Hope that helps.

phyatt
  • 18,472
  • 5
  • 61
  • 80