QDirModel and QListView > problem getting filepath
Hello guys. QT Newb here. Having a bad day...
First will show some code:
Code:
void ImCo::createDockWindows()
{
dock->setAllowedAreas(Qt::RightDockWidgetArea);
dirmodel
->setFilter
(QDir::Files |
QDir::NoSymLinks);
dirmodel
->setSorting
(QDir::Name);
listView->setModel(dirmodel);
listView
->setRootIndex
(dirmodel
->index
(QDir::currentPath() + "/frames"));
dock->setWidget(listView);
addDockWidget(Qt::RightDockWidgetArea, dock);
opt->addAction(dock->toggleViewAction());
}
int r = index.row();
// I click on one of the files showed on the QListView, and i need the path to the clicked file !!!
ww.some_func(path_to_the_file, var1, var2...);//this func needs the path to the file so it can be opened from other class
}
I`m forming a dock window which is showing the contents of a directory underneath my executable. When i click on a file on the dock QListView i want to call a function which has a parameter with a path to the file i clicked on the listView. So my question is: how to get the path to the file i clicked for the function ImCo::test. I only get the number of the item trough index.row. I don`t know how to get the filepath from the dirmodel. Hope i explained it well. Thanx in advance.
Re: QDirModel and QListView > problem getting filepath
I would say - read the docs. There're enough functions where you can retrieve informations about the current file from the model index.
Re: QDirModel and QListView > problem getting filepath
Wow, how can i miss those... starting now on fresh mind and it seems so easy lol
I think i needed a rest the last night.
Thank you :)