PDA

View Full Version : Dynamically changing QFrame color



Doug Broadwell
18th October 2006, 02:22
How can I dynamically change the color of a QFrame border (shape = box, shadow = plain) ?

Thanks

munna
18th October 2006, 09:10
You can use QPalette for this.

Doug Broadwell
18th October 2006, 15:43
Does a QFrame have Disabled, Active and Inactive states that can be set to change its color or is changing the palette the only way to do this?

Thanks

jpn
18th October 2006, 16:12
Use QPalette::setColor(ColorGroup gr, ColorRole r, const QColor & c) where the color group is one of the following:

QPalette::Disabled
QPalette::Active
QPalette::Inactive
QPalette::Normal

Doug Broadwell
18th October 2006, 18:22
OK, but what ColorRole do I use?

Thanks

wysota
19th October 2006, 13:37
Experiment. There is a preview if you use Designer. There is also another possibility if you use 4.2 - String (aka Style) Sheets.

gimel
16th October 2008, 09:22
Under Vista+Qt 4.4.1, QPalette is not functional for this. Use frame->setStyleSheet("color:red") to change the border color.