PDA

View Full Version : Don't u nderstand how to use the palette in Qt Designer



dpetican
28th August 2016, 18:46
Can someone link me to an explanation of what the different palette elements do and under what circumstances certain palette elements might or might be available/applicable. I'm having a very hard time doing something as simple as changing the background colour of a button when its active/disabled. However, there's no problem changing the button text for active/inactive. Whats the difference (should there be?) between running my program on windows and on my target embedded system. Does it have something to do with styles? If so how do I change the style on windows so its reflects the style I'm using (but haven't explicitly set) on my Raspberry Pi using PyQt4? Thanks.

d_stranz
29th August 2016, 01:12
Reading the documentation for QPalette, especially QPalette::ColorRole and QPalette::ColorGroup should answer a lot of questions.

In C++ at least, QPalette is typically used like this:



QPushButton * myButton = new QPushButton( this );
QPalette pal = myButton->palette();

pal.setColor( QPalette::Disabled, QPalette::Button, Qt::gray );

myButton->setPalette( pal );


The default styles used on the RPi and desktop will almost certainly be different. Again, the documentation for QStyle explains this, and gives an example of how you can start an app with a different style than the default on the platform where you are running it.