Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

about options #18

Open
hezhongfeng opened this issue Apr 26, 2016 · 5 comments
Open

about options #18

hezhongfeng opened this issue Apr 26, 2016 · 5 comments
Labels

Comments

@hezhongfeng
Copy link

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
Copy link
Owner

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)

@hezhongfeng
Copy link
Author

@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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Owner

gamecreature commented Apr 29, 2016

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants