Qt/C++ - Set background of disabled button? -


i have buttons disabled in grid, some, i'd change background color. i'm trying:

_fieldbuttons[0][0]->setstylesheet("color: blue; background-color: blue;"); 

where

qvector<qvector<qpushbutton*> > _fieldbuttons; 

however, these buttons disabled, , text color gets changed:

enter image description here

how can change background, not text? thank you!

update figured it's not working because buttons flat. how can change flat button colors?

two options:

  1. add border: none; stylesheet.

  2. use setautofillbackground(true) in conjunction qpalette::button

    mybutton->setflat(true); mybutton->setautofillbackground(true); qpalette pal = mybutton->palette(); pal.setcolor(qpalette::button, qcolor(qt::blue)); mybutton->setpalette(pal); 

http://doc.qt.io/qt-5/qpushbutton.html#flat-prop


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -