Qt Mac应用程序存储数据路径

时间:2018-02-11 09:45:16

标签: c++ macos qt app-store

我有一个被拒绝的应用程序,通过检查它,我发现我需要在应用程序包中写入(我还不清楚)。 我使用了以下代码Qt 5.9.1:

QStandardPaths::StandardLocation type = static_cast<QStandardPaths::StandardLocation>(QStandardPaths::DataLocation);
QString directory = QStandardPaths::writableLocation(type);

当我调试qt creator中的路径时,它是 directory =“/ Users / myname / Library / Application Support / Myname / Myapplicaiton”

我尝试了以下相同的结果

QString directory = QStandardPaths::standardLocations(QStandardPaths::AppDataLocation).first();

但是我们需要在应用程序包中添加数据。据我所知,它应该是myapplication.app \ data \(如果有误,请纠正我)

在appt应用程序的Qt中定义路径的正确方法是什么?

有没有办法提供写入此路径的权限?

谢谢

1 个答案:

答案 0 :(得分:0)

在MAC上试试这个:

auto path =  QStandardPaths::writableLocation(QStandardPaths::HomeLocation);
path += "/data";