Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Customised file manager
Qt 6.11 is out! See what's new in the release blog

Customised file manager

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 3 Posters 670 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nemooo
    wrote on last edited by
    #1

    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.

    VRoninV 1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      What do you want to show in that additional column ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • N Offline
        N Offline
        Nemooo
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • N Nemooo

          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.

          VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          @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

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          N 1 Reply Last reply
          3
          • VRoninV VRonin

            @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

            N Offline
            N Offline
            Nemooo
            wrote on last edited by
            #5

            @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

            VRoninV 1 Reply Last reply
            0
            • N Nemooo

              @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

              VRoninV Offline
              VRoninV Offline
              VRonin
              wrote on last edited by
              #6

              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.html

              for 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.

              "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
              ~Napoleon Bonaparte

              On a crusade to banish setIndexWidget() from the holy land of Qt

              N 1 Reply Last reply
              4
              • VRoninV VRonin

                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.html

                for 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.

                N Offline
                N Offline
                Nemooo
                wrote on last edited by
                #7

                @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.html

                for 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

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved