been_1990
3rd May 2009, 00:35
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;
qDebug() << QDesktopServices::openUrl(o);
}
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::openUrl(o); --> --> false
I did some testing and passing this:
QUrl dir = directory+"\\"+var.data(0).toString();
qDebug() << QDesktopServices::openUrl(dir);
still gives me:
qDebug() << QDesktopServices::openUrl(dir); --> --> false
Any idea why?
The following is my "file-opening" function:
void MainWindow::click2(const QModelIndex &var/*index*/)
{
QString o = var.data(0).toString();
qDebug() << o;
qDebug() << QDesktopServices::openUrl(o);
}
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::openUrl(o); --> --> false
I did some testing and passing this:
QUrl dir = directory+"\\"+var.data(0).toString();
qDebug() << QDesktopServices::openUrl(dir);
still gives me:
qDebug() << QDesktopServices::openUrl(dir); --> --> false
Any idea why?