Qt:通过Unicode访问时,更改Qt中FontAwesome使用的图标的颜色。

时间:2017-01-16 10:51:52

标签: c++ qt unicode font-awesome qicon

我编写了一个代码来打印从系统中安装的FontAwesome访问的Icon。我想更改Screen上打印的Icon的颜色。我尝试过使用QPixmap和QIcon,但无济于事。附加输出:enter image description here

#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;
}

0 个答案:

没有答案