标签:style http color get 使用 strong
#ifndefICONHELPER_H
#defineICONHELPER_H #include<QObject> #include<QMutex> #include<QMutexLocker> #include<QtGui> #include<QtWidgets> #include<qfont.h> classIconHelper:publicQObject { Q_OBJECT
private:
explicitIconHelper(QObject*parent=0); QFonticonFont; staticIconHelper*_instance; public:
staticIconHelper*Instance() { staticQMutexmutex; if(!_instance) { QMutexLockerlocker(&mutex);
if(!_instance) { _instance=newIconHelper; } } return_instance; } voidSetIcon(QLabel*ctl,QCharc,intsize=10); voidSetIcon(QPushButton*ctl,QCharc,intsize=10); signals:
publicslots: }; #endif//ICONHELPER_H |
#include"IconHelper.h" IconHelper*IconHelper::_instance=0; IconHelper::IconHelper(QObject*): QObject(qApp) { intfontId=QFontDatabase::addApplicationFont(qApp->applicationDirPath()+"/res/fontawesome-webfont.ttf"); QStringfontName=QFontDatabase::applicationFontFamilies(fontId).at(0); iconFont=QFont(fontName); } voidIconHelper::SetIcon(QLabel*ctl,QCharc,intsize) { iconFont.setPointSize(size);
ctl->setFont(iconFont);
ctl->setText(c); } voidIconHelper::SetIcon(QPushButton*ctl,QCharc,intsize) { iconFont.setPointSize(size);
ctl->setFont(iconFont);
ctl->setText(c); } |
IconHelper::Instance()->SetIcon(ui->LeftBtn,QChar(0xf177),12); IconHelper::Instance()->SetIcon(ui->RightBtn,QChar(0xf178),12); |
分享我用Qt开发的应用程序【二】在Qt应用程序中使用字体图标fontawesome,布布扣,bubuko.com
分享我用Qt开发的应用程序【二】在Qt应用程序中使用字体图标fontawesome
标签:style http color get 使用 strong
原文地址:http://www.cnblogs.com/liulun/p/3797795.html