Results 1 to 2 of 2

Thread: Problem in getting data using QFileSystemModel

  1. #1
    Join Date
    Feb 2010
    Posts
    8
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows Symbian S60

    Default Problem in getting data using QFileSystemModel

    Hi ,

    I am using QFileSystemModel to find the filenames, filesize, fileIcon and filePath of the files placed in C drive. So i used the QFileSystemModel.

    The rowCount returns 0 and columnCount returns 4 .I dont understand the reason ? Please tell if there is anything that i can use to get the data apart from QFileSystemModel.
    QFileSystemModel* fileModel = new QFileSystemModel;QModelIndex index = fileModel->setRootPath(QString("C:/"));
    QString rootpath = fileModel->rootPath();
    qDebug() << rootpath;
    int rowCount = fileModel->rowCount();
    int columnCount = fileModel->columnCount();

  2. #2
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Problem in getting data using QFileSystemModel

    It probably hasn't completed by the time it reaches your "int rowCount = fileModel->rowCount();", as the calls are asynchronous.

    You really shouldn't be using QFileSystemModel to just retrieve the contens of a directory. Have a look at classes such as QDir instead. QFileSystemModel is meant to be used as a MVC.

Similar Threads

  1. QFileSystemModel: creating custom rows of data
    By masterlaws in forum Qt Programming
    Replies: 3
    Last Post: 12th August 2013, 12:58
  2. Replies: 2
    Last Post: 16th July 2010, 20:14
  3. Help with QFileSystemModel
    By TheShow in forum Qt Programming
    Replies: 4
    Last Post: 5th January 2010, 21:11
  4. Known problem with filters and QFileSystemModel?
    By Kumosan in forum Qt Programming
    Replies: 3
    Last Post: 27th August 2009, 09:14
  5. QDirModel or QFileSystemModel?
    By ricardo in forum Qt Programming
    Replies: 1
    Last Post: 21st June 2009, 18:10

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.