change to asset read

This commit is contained in:
王劲鹏
2021-06-10 11:05:31 +08:00
committed by osborn
parent 0b4b9c2ed6
commit e6cff004d0
7 changed files with 30 additions and 7 deletions

View File

@@ -24,6 +24,19 @@ public:
return content;
}
static QString readAssetFile(QString resourcePath) {
QResource resource(":" + resourcePath);
QFile *file = new QFile(resource.fileName());
file->open(QFile::ReadOnly | QFile::Text);
QTextStream in(file);
in.setCodec("UTF-8");
QString content = in.readAll();
file->close();
delete file;
return content;
}
template <typename Base, typename T>
static inline bool instanceof (const T *) {
return std::is_base_of<Base, T>::value;