Hello guys. QT Newb here. Having a bad day...
First will show some 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
}
void ImCo::createDockWindows()
{
dock = new QDockWidget(tr("Available Frames"), this);
dock->setAllowedAreas(Qt::RightDockWidgetArea);
dirmodel = new QDirModel;
dirmodel->setFilter(QDir::Files | QDir::NoSymLinks);
dirmodel->setSorting(QDir::Name);
listView = new QListView();;
listView->setModel(dirmodel);
listView->setRootIndex(dirmodel->index(QDir::currentPath() + "/frames"));
dock->setWidget(listView);
connect(listView, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(test(const QModelIndex &)));
addDockWidget(Qt::RightDockWidgetArea, dock);
opt->addAction(dock->toggleViewAction());
}
void ImCo::test(const QModelIndex &index){
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
}
To copy to clipboard, switch view to plain text mode
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.
Bookmarks