QT加载自带字体
#include <QCoreApplication> #include <QStringList> #include <QFontDatabase> #include <QFont>
QFont font;
int index = QFontDatabase::addApplicationFont(":/Font/Resources/font/Quartz.ttf");
if (index != -1)
{
QStringList fontList(QFontDatabase::applicationFontFamilies(index));
if (fontList.count() > 0)
{
font.setFamily(fontList.at(0));
font.setBold(false);
}
}
QLabel* label = new QLabel("腾讯QQ", this);
label->setFont(font);