Results 1 to 2 of 2

Thread: How to get 2nd column data from QFileSystemModel on QListView

  1. #1
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    252
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default How to get 2nd column data from QFileSystemModel on QListView

    I'm using a QFileSystemModel to show data on both QTableView & QListView. Instead of default data, I want to show the data from 3nd column in the model on QListView.
    How can I do that?

    fsmodel.jpg

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication a(argc, argv);
    4.  
    5. QStringList numbers;
    6. numbers << "One" << "Two" << "Three" << "Four" << "Five";
    7.  
    8. QFileSystemModel *model = new QFileSystemModel;
    9. model->setRootPath(QDir::currentPath());
    10.  
    11. QSplitter * splitter = new QSplitter;
    12. QTableView *table = new QTableView(splitter);
    13. QListView * list = new QListView(splitter);
    14.  
    15. table->setModel(model);
    16. list->setModel(model);
    17.  
    18. splitter->show();
    19.  
    20. return a.exec();
    21. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by rawfool; 7th October 2022 at 22:03.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,153
    Thanks
    295
    Thanked 854 Times in 841 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to get 2nd column data from QFileSystemModel on QListView

    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. The following user says thank you to d_stranz for this useful post:

    rawfool (8th October 2022)

Similar Threads

  1. Replies: 1
    Last Post: 20th November 2015, 10:12
  2. Filter QListView/QTreeView using QFileSystemModel
    By Alundra in forum Qt Programming
    Replies: 1
    Last Post: 17th September 2015, 16:55
  3. QFileSystemModel and custom column / data
    By ArnSpin in forum Newbie
    Replies: 4
    Last Post: 2nd March 2015, 13:07
  4. Replies: 4
    Last Post: 27th February 2014, 10:42
  5. how use QFileSystemModel with QListView ?
    By lwifi in forum Qt Programming
    Replies: 4
    Last Post: 26th April 2010, 04:41

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.