字体要加到.qrc文件中
QString Widget::loadFontFamilyFromTTF() { static QString font; static bool loaded = false; if(!loaded) { loaded = true; int loadedFontID = QFontDatabase::addApplicationFont(":/new_font.FON"); QStringList loadedFontFamilies = QFontDatabase::applicationFontFamilies(loadedFontID); if(!loadedFontFamilies.empty()) font = loadedFontFamilies.at(0); } return font; }
by 寒山-居士 https://bbs.csdn.net/topics/390707337