[solved] QDesktopServices::storageLocation substituion in Qt 5
-
Hello,
I'm trying to port my desktop application to Qt 5, stumbled upon
@QDesktopServices::storageLocation( QDesktopServices::DataLocation );@
Can't find a substitute in Qt 5, please advise.
-
You can use "QStandardPaths":http://qt-project.org/doc/qt-5.0/qtcore/qstandardpaths.html (from the QtCore module) as a replacement for QDesktopServices.
-
[quote author="Terence" date="1356185483"]You can use "QStandardPaths":http://qt-project.org/doc/qt-5.0/qtcore/qstandardpaths.html (from the QtCore module) as a replacement for QDesktopServices.[/quote]
Thanks a lot!
-
Thanks for suggestion Terence.
-
Please help me for my one program to create, I have some code that created QT 4.8 now i open in QT 5.2 but facing some problem, please see the code & give me solution.
--------------------------------------------Thax--------------------------------------------------
#ifndef STDLOCATION_H
#define STDLOCATION_H#include <QDir>
#include <QFileInfo>
#include <QDesktopServices>
#include <QDateTime>
#include "settings.h"#define SL_TRANSFERHISTORY "transfers.lst"
#define SL_FILESTORAGEDIR "Received Files"
#define SL_CACHEDIR "cache"
#define SL_RESOURCE "lmc.rcc"
#define SL_LANGDIR "lang"
#define SL_THEMEDIR "themes"
#define SL_GROUPFILE "group.cfg"
#define SL_AVATARFILE "avt_local.png"
#define SL_LOGDIR "logs"
#define SL_TEMPCONFIG "lmctmpconf.ini"class StdLocation {
public:
static QString transferHistory(void) {
return QDir::toNativeSeparators(QDesktopServices::storageLocation(
QDesktopServices::DataLocation) + "/"SL_TRANSFERHISTORY);
}static QString fileStorageDir(void) {
lmcSettings settings;QString path = QDir::toNativeSeparators(QDesktopServices::storageLocation(
QDesktopServices::DocumentsLocation) + "/"SL_FILESTORAGEDIR);
path = settings.value(IDS_FILESTORAGEPATH, path).toString();
return path;
}static QString cacheDir(void) {
return QDir::toNativeSeparators(QDesktopServices::storageLocation(
QDesktopServices::DataLocation) + "/"SL_CACHEDIR);
}static QString libDir(void) {
return QDir::toNativeSeparators(QDir::currentPath());
}static QString resourceFile(void) {
return QDir::toNativeSeparators(QDir::current().absoluteFilePath(SL_RESOURCE));
}static QString resLangDir(void) {
return ":/"SL_LANGDIR;
}static QString sysLangDir(void) {
return QDir::toNativeSeparators(QDir::currentPath() + "/"SL_LANGDIR);
}static QString userLangDir(void) {
return QDir::toNativeSeparators(QDesktopServices::storageLocation(
QDesktopServices::DataLocation) + "/"SL_LANGDIR);
}static QString resThemeDir(void) {
return ":/"SL_THEMEDIR;
}static QString sysThemeDir(void) {
return QDir::toNativeSeparators(QDir::currentPath() + "/"SL_THEMEDIR);
}static QString userThemeDir(void) {
return QDir::toNativeSeparators(QDesktopServices::storageLocation(
QDesktopServices::DataLocation) + "/"SL_THEMEDIR);
}static QString groupFile(void) {
return QDir::toNativeSeparators(QDesktopServices::storageLocation(
QDesktopServices::DataLocation) + "/"SL_GROUPFILE);
}static QString avatarFile(void) {
return QDir::toNativeSeparators(QDesktopServices::storageLocation(
QDesktopServices::DataLocation) + "/"SL_AVATARFILE);
}static QString logDir(void) {
return QDir::toNativeSeparators(QDesktopServices::storageLocation(
QDesktopServices::DataLocation) + "/"SL_LOGDIR);
}static QString freeLogFile(void) {
QString fileName = "lmc_" +
QString::number(QDateTime::currentDateTimeUtc().toMSecsSinceEpoch()) + ".log";
return QDir::toNativeSeparators(logDir() + "/" + fileName);
}static QString tempConfigFile(void) {
return QDir::toNativeSeparators(QDesktopServices::storageLocation(
QDesktopServices::TempLocation) + "/"SL_TEMPCONFIG);
}
};#endif // STDLOCATION_H
-
Instead of using
@QString QDesktopServices::storageLocation ( StandardLocation type ) [static]@in Qt4 use: @QStandardPaths::standardLocations(StandardLocation type) [static]@ in Qt5. Check documentation "here":http://qt-project.org/doc/qt-5.0/qtcore/qstandardpaths.html#standardLocations.
-
Please help me.
How can i convert QT 4.8 code - To - QT 5.2 code that i indeed.
--------------------------------------------Thax--------------------------------------------------#ifndef STDLOCATION_H
#define STDLOCATION_H#include <QDir>
#include <QFileInfo>
#include <QDesktopServices>
#include <QDateTime>
#include "settings.h"#define SL_TRANSFERHISTORY "transfers.lst"
#define SL_FILESTORAGEDIR "Received Files"
#define SL_CACHEDIR "cache"
#define SL_RESOURCE "lmc.rcc"
#define SL_LANGDIR "lang"
#define SL_THEMEDIR "themes"
#define SL_GROUPFILE "group.cfg"
#define SL_AVATARFILE "avt_local.png"
#define SL_LOGDIR "logs"
#define SL_TEMPCONFIG "lmctmpconf.ini"class StdLocation {
public:static QString transferHistory(void) {
return QDir::toNativeSeparators(QDesktopServices::storageLocation(
QDesktopServices::DataLocation) + "/"SL_TRANSFERHISTORY);
}static QString fileStorageDir(void) {
lmcSettings settings;QString path = QDir::toNativeSeparators(QDesktopServices::storageLocation(
QDesktopServices::DocumentsLocation) + "/"SL_FILESTORAGEDIR);
path = settings.value(IDS_FILESTORAGEPATH, path).toString();
return path;
}static QString cacheDir(void) {
return QDir::toNativeSeparators(QDesktopServices::storageLocation(
QDesktopServices::DataLocation) + "/"SL_CACHEDIR);
}static QString libDir(void) {
return QDir::toNativeSeparators(QDir::currentPath());
}static QString resourceFile(void) {
return QDir::toNativeSeparators(QDir::current().absoluteFilePath(SL_RESOURCE));
}static QString resLangDir(void) {
return ":/"SL_LANGDIR;
}static QString sysLangDir(void) {
return QDir::toNativeSeparators(QDir::currentPath() + "/"SL_LANGDIR);
}static QString userLangDir(void) {
return QDir::toNativeSeparators(QDesktopServices::storageLocation(
QDesktopServices::DataLocation) + "/"SL_LANGDIR);
}static QString resThemeDir(void) {
return ":/"SL_THEMEDIR;
}static QString sysThemeDir(void) {
return QDir::toNativeSeparators(QDir::currentPath() + "/"SL_THEMEDIR);
}static QString userThemeDir(void) {
return QDir::toNativeSeparators(QDesktopServices::storageLocation(
QDesktopServices::DataLocation) + "/"SL_THEMEDIR);
}static QString groupFile(void) {
return QDir::toNativeSeparators(QDesktopServices::storageLocation(
QDesktopServices::DataLocation) + "/"SL_GROUPFILE);
}static QString avatarFile(void) {
return QDir::toNativeSeparators(QDesktopServices::storageLocation(
QDesktopServices::DataLocation) + "/"SL_AVATARFILE);
}static QString logDir(void) {
return QDir::toNativeSeparators(QDesktopServices::storageLocation(
QDesktopServices::DataLocation) + "/"SL_LOGDIR);
}static QString freeLogFile(void) {
QString fileName = "lmc_" +
QString::number(QDateTime::currentDateTimeUtc().toMSecsSinceEpoch()) + ".log";
return QDir::toNativeSeparators(logDir() + "/" + fileName);
}static QString tempConfigFile(void) {
return QDir::toNativeSeparators(QDesktopServices::storageLocation(
QDesktopServices::TempLocation) + "/"SL_TEMPCONFIG);
}
};#endif // STDLOCATION_H
-
Please explain sir
Waiting for your kind information.
Thank you
-
I wrote you my answer. What else you want me to explain you? I think with minimum effort you can fix this problem yourself.
-
Sir,
Please solved this code. then i'll try to solve alone another script(code)
Thank you.static QString transferHistory(void) {
return QDir::toNativeSeparators(QDesktopServices::storageLocation(
QDesktopServices::DataLocation) + "/"SL_TRANSFERHISTORY);
} -
@#include <QtCore/QDir>
#include <QtCore/QStandardPaths>static QString transferHistory(void)
{
return QDir::toNativeSeparators(QStandardPaths::standardLocations(QStandardPaths::DataLocation).at(0));
}@ -
where is missing script?
#define SL_TRANSFERHISTORY "transfers.lst"
"/"SL_TRANSFERHISTORY
-
Please help me with header define script solved qt 5.2
thax & thax
#define SL_FILESTORAGEDIR
static QString fileStorageDir(void) {
lmcSettings settings;QString path = QDir::toNativeSeparators(QDesktopServices::storageLocation(
QDesktopServices::DocumentsLocation) + "/"SL_FILESTORAGEDIR);
path = settings.value(IDS_FILESTORAGEPATH, path).toString();
return path;
} -
Thanks advanced, please...