The problem is that you are trying to concatenate a QStringList with QStrings since
QStandardPaths::standardLocations(QStandardPaths::HomeLocation)
returns a QStringList
.
You would need to gt the element you wish to reuse, e.g. using the .first()
method. You could write this:
MainPath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first() + "/" + a.applicationName() + "/Data";
Note that I just added a missing "/" between the application name and the "Data" because I think that would be more logical to use, but feel free to reject that edit if you wish.
But since you seem to be interested in the data directory location, I would suggest to use the dedicated enum from QStandardPaths
:
or it would be even better to just use:
QStandardPaths::DataLocation 9 Returns a directory location where persistent application data can be stored. QCoreApplication::organizationName and QCoreApplication::applicationName are appended to the directory location returned for GenericDataLocation.
You could write this then:
QDir Path(QStandardPaths::standardLocations(QStandardPaths::DataLocation).first());
In fact, if you wish to avoid the .first()
call, you could probably use the writableLocation() method as follows:
QDir Path(QStandardPaths::writableLocation(QStandardPaths::DataLocation));
=====================================================
Out of curiosity, this could also be an alternative:
QString QDir::homePath () [static]
or
QDir QDir::home () [static]
as follows:
QDir Path = QDir::home();
Path.cd(a.applicationName() + "Data");
or
QDir Path(QDir::homePath() + "/" + a.applicationName() + "/Data");
If that is not enough, there is even one more alternative:
QDir Path(QCoreApplication::applicationDirPath + "/Data");