gpt4 book ai didi

QT 在 *nix 上打开默认文件资源管理器

转载 作者:行者123 更新时间:2023-12-03 03:30:30 25 4
gpt4 key购买 nike

我有以下内容:

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

我如何才能在 Ubuntu 上实现相同的行为?

最佳答案

使用QDesktopServices及其 openUrl 函数:

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

它应该适用于所有操作系统。我只在 Windows 中测试过。

关于QT 在 *nix 上打开默认文件资源管理器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3569749/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com