QT Open default file explorer on *nix

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?

Answers


Use QDesktopServices and its openUrl function:

QString path = QDir::toNativeSeparators(QApplication::applicationDirPath());
QDesktopServices::openUrl(QUrl::fromLocalFile(path));

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


Need Your Help

Compare RGB colors in c#

c# colors compare rgb

I'm trying to find a way to compare two colors to find out how much they are alike. I can't seem to find any resources about the subject so I'm hoping to get some pointers here.

cmake doesn't recognize CMAKE_ECLIPSE_VERSION setting

eclipse variables cmake eclipse-cdt

I'm trying to generate an eclipse .project and .cproject from an existing cmake file. Running cmake from the project root I tried adding to the root CMakeLists.txt