This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Doric/doric-Qt/doric/utils/DoricUtils.h
2021-05-20 18:27:45 +08:00

26 lines
563 B
C++

#ifndef UTILS_H
#define UTILS_H
#include <QFile>
#include <QResource>
#include <QString>
#include <QTextStream>
class DoricUtils {
public:
static QString readAssetFile(QString preffix, QString assetName) {
QResource resource(":" + preffix + "/" + assetName);
QFile *file = new QFile(resource.fileName());
file->open(QFile::ReadOnly | QFile::Text);
QTextStream in(file);
in.setEncoding(QStringConverter::Encoding::Utf8);
QString content = in.readAll();
file->close();
delete file;
return content;
}
};
#endif // UTILS_H