PDA

View Full Version : Change color of QButton does not work with GTK



Teuniz
18th March 2009, 16:06
I'm using Qt 4.5.0

I use this code to change the color of a QButton:

SigColorButton->setPalette(QPalette((Qt::GlobalColor)mainwindow->maincurve->signal_color));

This works with Plastic and windows style but not with GTK style...

After compilation, when I run the app with "app -style plastic" or "app -style windows" it's ok. It's not ok when I try "app -style gtk".

OS is Linux, tried on OpenSUSE and Ubuntu. GTK2 development files are installed and Qt was configured to use GTK-style.
The GTK-style does work, problem is that I can not change the color of a QButton when using GTK style.

Any ideas?

wysota
18th March 2009, 18:54
Use stylesheets. Some styles (apparently GTK included) don't allow to change the looks of some items, like colours of buttons because the underlying backend (such as Vista's Aero) doesn't support such operations and the style is not emulated but used.

Teuniz
19th March 2009, 07:43
Use stylesheets. Some styles (apparently GTK included) don't allow to change the looks of some items, like colours of buttons because the underlying backend (such as Vista's Aero) doesn't support such operations and the style is not emulated but used.
Thanks, what do you mean with stylesheets?
I don't want to change the style and/or all the buttons.
I have two dialogs with some buttons and only these particular buttons needs to be recoloured.

Isn't it better to write my own buttonwidget or inherit from QButton and change some properties?

wysota
19th March 2009, 09:12
Thanks, what do you mean with stylesheets?
Qt Stylesheets


Isn't it better to write my own buttonwidget or inherit from QButton and change some properties?

It wouldn't change anything. You'd have to draw the whole button yourself.