QT加载自带字体

#include 
#include 
#include 
#include 

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);

 

你可能感兴趣的:(QT加载自带字体)