Unsolved Customised file manager
-
Hello!
I am new in Qt. Everything begun when I tried to add additional columns in QFileSystemModel. I didn't find the solution. By I got some hints that it is possible to create my own model using QStandardItemModel. I have found something like this:const QIcon fileIcon = qApp->style()->standardPixmap(QStyle::SP_FileIcon); const QIcon dirIcon = qApp->style()->standardPixmap(QStyle::SP_DirIcon); QStandardItemModel model(0, 2); QFileInfoList files = QDir("/Users").entryInfoList(); foreach(const QFileInfo &fi, files) { QStandardItem *item = new QStandardItem(QString("%0").arg(fi.fileName())); item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); if (fi.isDir()) item->setData(dirIcon, Qt::DecorationRole); else item->setData(fileIcon, Qt::DecorationRole); model.appendRow(item); } QTreeView view; view.setModel(&model); view.show();
Of course it is far from real QFileSystemModel. At least I don't know how to create QObject::connect to open folders when you click so it reminds to real file manager where I could have more than 5 columns (for example for media info).
Can anybody give me some hints please.Thank you.
-
Hi and welcome to devnet,
What do you want to show in that additional column ?
-
Hi. I want to write a program that calculates selected audio files duration. I need a column that shows audio files durations (min, sec) and when I select some of them somewhere I create QLabel which shows resulted durations sum. The column with audio durations is just for convenience.
-
@Nemooo said in Customised file manager:
Everything begun when I tried to add additional columns in QFileSystemModel. I didn't find the solution.
The solution is KExtraColumnsProxyModel. The author is the maintainer of anything relating to models in Qt.
If you use MSVC2017 compiler you can find a pre-compiled version of the library containing that class here: 32 bit/64 bit
-
@VRonin
Thank you very much, but I don't know how to use and attach it. Moreover I would like to use standard Qt library for training -
I don't know how to use and attach it
https://doc.qt.io/qt-5/third-party-libraries.html
https://doc.qt.io/qtcreator/creator-project-qmake-libraries.htmlfor training
Being able to use 3rd party libraries is a must-have for a programmer. Way more important (I can't stress this enough) than knowing how to implement a custom proxy model.
-
@VRonin said in Customised file manager:
I don't know how to use and attach it
https://doc.qt.io/qt-5/third-party-libraries.html
https://doc.qt.io/qtcreator/creator-project-qmake-libraries.htmlfor training
Being able to use 3rd party libraries is a must-have for a programmer. Way more important (I can't stress this enough) than knowing how to implement a custom proxy model.
Thank you very much. I will try to attach this library