I created a app directory browser using QListView, to display my desktop items.
The following is my "file-opening" function:
void MainWindow
::click2(const QModelIndex &var
/*index*/) {
QString o
= var.
data(0).
toString();
qDebug() << o;
}
void MainWindow::click2(const QModelIndex &var/*index*/)
{
QString o = var.data(0).toString();
qDebug() << o;
qDebug() << QDesktopServices::openUrl(o);
}
To copy to clipboard, switch view to plain text mode
So with that and my index set as current directory, I can open any file.But if I change its index to any other directory thats not its current, it fails and qDebug says :
qDebug() << QDesktopServices:penUrl(o); --> --> false
I did some testing and passing this:
QUrl dir
= directory
+"\\"+var.
data(0).
toString();
QUrl dir = directory+"\\"+var.data(0).toString();
qDebug() << QDesktopServices::openUrl(dir);
To copy to clipboard, switch view to plain text mode
still gives me:
qDebug() << QDesktopServices:penUrl(dir); --> --> false
Any idea why?
Bookmarks