Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFileSystemModel add Column
Qt 6.12 LTS is out! See what's new in the release blog

QFileSystemModel add Column

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 628 Views 2 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.
  • S Offline
    S Offline
    Sikarjan 0
    wrote on last edited by
    #1

    Hi there!

    I see that there are serval posts regarding this topic but all are rather old and none really added a column to QFileSystemModel. So is it really possible to add a column?

    My plan is to add two columns to hold a temp string per file and a bool value if this temp string was modified. This is what I did so far:

        model = new FileModel(this);
        model->insertColumns(model->columnCount(),2);
    

    FileModel is my custom class that I derived from QFileSystemModel. I create indexes to access the two additional information like this:

    QModelIndex noteChanged = createIndex(index.row(), 5);
    

    And access the data like this:

    this->data(index);
    

    This is not working. Can it work in this way? I would like to use QFileSystemModel to have the option to rename files, add/delete files and watch a directory.

    Alternatively I was wandering if I could add additional roles to the model. Like a Qt::TempNote and Qt::NoteChanged role, which would hold my additional values.

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

      Hi,

      You might want to check KExtraColumnsProxyModel to add your additional columns.

      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

      • Login

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