Frage

Ich habe folgende:

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

Wie kann ich das gleiche Verhalten erreichen Let Ubuntu sagen?

War es hilfreich?

Lösung

Verwenden Sie QDesktopServices und seine Openurl Funktion:

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

Es sollte mit allen OS'es arbeiten. Ich habe es nur in Windows getestet.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top