gamecreature / QtAwesome

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

about options #18

Open hezhongfeng opened 8 years ago

hezhongfeng commented 8 years ago

I set 3 colors for 3 widgets,but the pushbutton has no role I don't know why..........

    QtAwesome *awesome = new QtAwesome();
    awesome->initFontAwesome();

    QVariantMap vmapRed;
    QVariantMap vmapBlue;
    QVariantMap vmapGreen;
    vmapRed.insert("color",QColor(Qt::red) );
    vmapBlue.insert("color",QColor(Qt::blue));
    vmapGreen.insert("color",QColor(Qt::darkGreen));

    ui->action513->setIcon(awesome->icon(fa::stop, vmapRed));
    ui->pushButton->setIcon(awesome->icon(fa::aligncenter, vmapBlue));
    ui->toolButton->setIcon(awesome->icon(fa::yelp, vmapGreen));
gamecreature commented 8 years ago

I tested the code above (for how far it's possible). I miss a lot of information.. When I create normal pushbutton/toolbutton and I apply your settings it simply works.

You tell me 'has no role'. Do you mean has no color?

Please supply with a complete example and more information about the environment. (Single main function just like sample supplied in QtAwesome)

hezhongfeng commented 8 years ago

@gamecreature thank your answer I don't how to show a screenshot so I will send you the project demo

'has no role' mean no color,just white

gamecreature commented 8 years ago

The issue does not occur on Mac OS X. It seems to be Windows specific

This is the screenshot that hezhongfeng has sent me... clip 04-26-12-44-08

This is how it looks on Mac OS X pastedgraphic-1

gamecreature commented 8 years ago

Well after some debugging I found the following 'problem'.

On Windows the default QIcon::State of a QPushButton seems to be 'active' So the button gets the color of the option 'color-active'. (which defaults to be black)

So in your case, you can use:

vmapBlue.insert("color",QColor(Qt::blue));
vmapBlue.insert("color-active",QColor(Qt::blue));

Don't know why this is the case, it's a Qt issue or feature..

gamecreature commented 8 years ago

Read some more about this active state. The QPushButton is active if it has focus. Probably your button is the only button on the screen and has got the keyboard focus.