gamecreature / QtAwesome

QtAwesome - Font Awesome for Qt Applications
Other
787 stars 149 forks source link

Icon not showing #20

Closed pyprism closed 7 years ago

pyprism commented 7 years ago

I am using Qt 5.7 . Icon is not showing as expected.

Login::Login(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::Login)
{
    ui->setupUi(this);
    ui->lineEdit_password->setEchoMode(QLineEdit::Password);
    QtAwesome* awesome = new QtAwesome(this);
    awesome->initFontAwesome();
    ui->pushButton->setIcon(awesome->icon( "sign-in" ));
    ui->pushButton_2->setIcon(awesome->icon( "user-plus" ));

}
gamecreature commented 7 years ago

I'm also running Qt 5.7..

Calling new QtAwesome(this) in a login dialog is going to give you some serious problems.. The QtAwesome object should be initialized only once! Every time you create and initialize the QtAwesome object it loads the fonts. And when the login closes the QtAwesome object is destroyed.

Please try to make it an application 'global' object an not a child of the Login dialog window.

Does the initFontAwesome() method return true/false or does it produce some debug output. The code above only contains a small hint of what is going on.

-- Just another hint:

please use the names as they are used in QtAwesome (the names are copied from their enum-value) It is 'signin' and 'userplus' (without the dash)