QtAwesome icon indicating copy to clipboard operation
QtAwesome copied to clipboard

about options

Open hezhongfeng opened this issue 9 years ago • 5 comments

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));

hezhongfeng avatar Apr 26 '16 02:04 hezhongfeng

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?

  • Is it possible, the button is disabled?
  • Is it possible the button doesn't show icons
  • Perhaps it's OS related?

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

gamecreature avatar Apr 26 '16 04:04 gamecreature

@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

hezhongfeng avatar Apr 26 '16 04:04 hezhongfeng

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 avatar Apr 26 '16 08:04 gamecreature

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 avatar Apr 29 '16 19:04 gamecreature

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.

gamecreature avatar Apr 29 '16 20:04 gamecreature