我正在尝试将以下代码转换为QT5版本:
QString getSaveFileName(QWidget *parent, const QString &caption,
const QString &dir,
const QString &filter,
QString *selectedSuffixOut)
{
QString selectedFilter;
QString myDir;
if(dir.isEmpty()) // Default to user documents location
{
myDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
}
else
但遗憾的是我收到了以下错误:
error: no member named 'storageLocation' in 'QDesktopServices'
myDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
~~~~~~~~~~~~~~~~~~^
和
error: no member named 'DocumentsLocation' in 'QDesktopServices'
myDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation);
~~~~~~~~~~~~~~~~~~^
答案 0 :(得分:3)
从Qt 5开始,storageLocation()
的{{1}}和displayName()
方法被QDesktopServices
类提供的功能所取代,因此您的QStandardPaths
可以像这样:
myDir