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/utils.h

27 lines
570 B
C
Raw Normal View History

2021-01-28 17:06:40 +08:00
#ifndef UTILS_H
#define UTILS_H
#include <QString>
#include <QResource>
#include <QFile>
#include <QTextStream>
class Utils
{
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);
2021-02-02 20:42:37 +08:00
in.setCodec("UTF-8");
2021-01-28 17:06:40 +08:00
QString content = in.readAll();
file->close();
delete file;
return content;
}
};
#endif // UTILS_H