views:

65

answers:

1

I have the following:

QProcess *process = new QProcess(this);
QString path = QDir::toNativeSeparators(QApplication::applicationPath);
#if defined(Q_OS_WIN)

process->start("explorer.exe",  QStringList() << path);

#elif defined(Q_OS_MAC)

process->start("open", QStringList() << path);

#endif

How I can achieve the same behavior for let say Ubuntu?

+5  A: 

Use QDesktopServices and its openUrl function:

QString path = QDir::toNativeSeparators(QApplication::applicationDirPath());
QDesktopServices::openUrl(QUrl("file:///" + path));

It should work with all OS'es. I have tested it only in Windows.

Roku
Works like charm on Windows XP SP2, Mac OSX 10.6.4, and Ubuntu.
Gad D Lord