4 Star 2 Fork 7

gxchip / GX_CodeGen

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
main.cpp 1.11 KB
一键复制 编辑 原始数据 按行查看 历史
taotieren 提交于 2024-04-11 10:39 . add linux
#include "mainwindow.h"
#include <QApplication>
#include <QDebug>
#include <QFile>
#include <QFontDatabase>
#include <QIODevice>
quint32 program_version = 0x01000101; // 1.1.1
QString loadFontFamilyFromFiles(const QString& fontFileName)
{
QString font = "";
QFile fontFile(fontFileName);
if (!fontFile.open(QIODevice::ReadOnly)) {
qDebug() << "Open font file error";
return font;
}
int loadedFontID = QFontDatabase::addApplicationFontFromData(fontFile.readAll());
QStringList loadedFontFamilies = QFontDatabase::applicationFontFamilies(loadedFontID);
if (!loadedFontFamilies.empty()) {
font = loadedFontFamilies.at(0);
}
fontFile.close();
return font;
}
int main(int argc, char* argv[])
{
QApplication a(argc, argv);
MainWindow w;
// QString strFont0 = loadFontFamilyFromFiles("fonts\\FangZhengHeiTiJianTi.ttf");
// qDebug() << "strFont0 is: " << strFont0;
// a.setFont(strFont0);
// QFont font;
// font.setFamily(strFont0);
// a.setFont(font);
// qApp->setFont(font);
w.show();
return a.exec();
}
C++
1
https://gitee.com/gxchip/GX_CodeGen.git
git@gitee.com:gxchip/GX_CodeGen.git
gxchip
GX_CodeGen
GX_CodeGen
master

搜索帮助