Setting a widget's QPalette to default?
I want a QLabel whose parent has a custom QPalette to have the default palette. What's the best way of doing that?
I thought it would just be something like:
Code:
label->setPalette(p);
But that doesn't work, label still inherits its parent's palette. Whether that's done before or after its parent's palette has changed from the default.
I found that
Code:
label->setPalette(p);
works. The label than gets the default QPalette::WindowText colour rather than its parent's. But that just confuses me further as I cannot see why the second code snippet would work but not the first.
So two questions. What is the best way to set a child widget's palette to the default if its parent uses a different palette. And why does the second code snippet have a different result than the first when they look like they should do the same thing?
Re: Setting a widget's QPalette to default?
Re: Setting a widget's QPalette to default?
Code:
// ho crap! no!
my_widget->setPalette( p );
// that's better
my_widget->setPalette( my_widget->style()->standardPalette() );