PDA

View Full Version : QFileSystemModel and QTableView



jesse_mark
22nd March 2013, 18:01
i have a QTableView and i want to use QFileSystemModel as its model.
so i tried this code ;



QFileSystemModel *model = new QFileSystemModel;
model->setRootPath(QDir::currentPath());
model->setFilter(QDir::Files);
tableView->setModel(model);


but the table does not show the files that are in the path. It just show one raw.

so, what is wrong am i doing ??? how can i make it get all the files ALSO how can I filter the files with a specific string , so it wont get ALL the files just the ones that meet my filter.

Thanks.

Added after 37 minutes:

ooh i was not using


tableView->setRootIndex(model->index(QDir::currentPath());

for filtering the files with name, i can use model->setNameFilters(QStringList filters).