James Bennet
James Bennet

Reputation: 3

Qt MVC - Get filename when user clicks?

Okay, I have the following code:

 QFileSystemModel *model = new QFileSystemModel;
 model->setRootPath(QDir::currentPath());
 model->setFilter(QDir::Files | QDir::NoSymLinks | QDir::NoDotAndDotDot |
                  QDir::Readable | QDir::Writable | QDir::CaseSensitive );

 ui->fileList->setModel(model);
 ui->fileList->setRootIndex(model->index(QDir::currentPath()));

How can I find out which item (specifically, its corresponding filename) has been selected? I want the user to select a file using the mouse, such that the selected filename can be passed to a method I have.

Upvotes: 0

Views: 304

Answers (1)

spraff
spraff

Reputation: 33385

Are you using QTreeWidget? It has an abstract item model. You need to get the model index from the selected item

Upvotes: 1

Related Questions