我编写了一个代码来打印从系统中安装的FontAwesome访问的Icon。我想更改Screen上打印的Icon的颜色。我尝试过使用QPixmap和QIcon,但无济于事。附加输出:
#include "MainWindow.h"
#include "ui_MainWindow.h"
#include <QPushButton>
#include <QGridLayout>
#include <QWidget>
#include <QLabel>
#include "qfonticon.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QWidget *centralWidget;
QGridLayout *gridLayout;
centralWidget = new QWidget(this);
gridLayout = new QGridLayout( centralWidget );
QFontIcon::addFont("/usr/share/fonts/fontawesome-webfont.ttf");
QIcon icon = QFontIcon::icon(0xf2e0,QColor(1,0,1,255));
//QFontIconEngine::addFile("/usr/share/fonts/fontawesome-webfont.ttf");
//QPixmap pix = QFontIconEngine::;
QPushButton *b = new QPushButton();
//QLabel *l = new QLabel();
b->setIcon(icon);
b->setIconSize(QSize(75,75));
//l->setPixmap(pix);
gridLayout->addWidget(b);
//gridLayout->addWidget(l);
this->setCentralWidget(centralWidget);
}
MainWindow::~MainWindow()
{
delete ui;
}