Qt_5.7 QDesktopServices
QDesktopServices可以打开:
1)本地文件(远程也可以)
2)获取桌面
3)我的文档
4)Home目录
5)打开网页
#include "mainwindow.h"
#include <QApplication>
#include <QDesktopServices>
#include <QUrl>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
//打开本地远程共享文件
QDesktopServices::openUrl(QUrl("file:///C:/Documents and Settings/All Users/Desktop", QUrl::TolerantMode));
//打开本地系统目录
QDesktopServices::openUrl(QUrl("C:/", QUrl::TolerantMode));
// 打开网页
QDesktopServices::openUrl(QUrl("https://blog.csdn.net/qq_36038987", QUrl::TolerantMode));
//获取系统相关的路径
QString desktop_path = QDesktopServices::storageLocation(QDesktopServices::DesktopLocation);
w.show();
return a.exec();
}