0

我编写了一个代码来打印从系统中安装的 FontAwesome 访问的图标。我想更改屏幕上打印的图标的颜色。我尝试使用 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;
}
4

0 回答 0