Hi,
I have some problems understanding the sense of QPalette::ColorRole.
I read the documentation a lot of times, and this is how I understood it:
Every QWidget uses a palette (QPalette) for design settings (BackgroundRole --> background color, ForegroundRole --> foreground color). Also, every QWidget has three states:
1. active (its parent window has focus)
2. inactive (another window has focus)
3. disabled
For each of these states, the QWidget's palette has a design setting (so each QWidget has three background colors, depending on its state).
Am I right so far?
Then, I was wondering about the fact that QPalette::ColorRole has more than one value for background settings:
- QPalette::Window
- QPalette::Base
- QPalette::Button
...
My guess is, that there are pre-defined colors for those "groups". Documentation says, QPalette::Window is used for basically window design, so I think it stands for grey background???
QPalette::Base is used by editable QWidgets (TextEdit/LineEdit, Table-/Listview and so on), and they all have a white background, so I guess this ColorRole stands for white background???
If all I mentioned above is right and I'm on the right way, then I don't understand why I can't do the following to change a QLineEdits background color to grey (like window background):
edit
->setBackgroundRole
(QPalette::Window);
QLineEdit* edit;
edit->setBackgroundRole(QPalette::Window);
To copy to clipboard, switch view to plain text mode
What I also do not understand is why the following works to set a red background:
edit->setPalette(palette);
QPalette palette;
palette.setColor(QPalette::Base, QColor(255,0,0));
QLineEdit* edit;
edit->setPalette(palette);
To copy to clipboard, switch view to plain text mode
, but this doesn't:
edit
->setBackgroundRole
(QPalette::Window);
edit->setPalette(palette);
QPalette palette;
palette.setColor(QPalette::Window, QColor(255,0,0));
QLineEdit* edit;
edit->setBackgroundRole(QPalette::Window);
edit->setPalette(palette);
To copy to clipboard, switch view to plain text mode
Why does a function of QLineEdit to change its backgroundRole (from standard QPalette::Base to some other) even exist when it does not work??
Well, I think I did not understand the whole thing and I'm totally on the wrong way. So if there is anyone who understands that all and wants to explain that to me, I would be really glad 
Thank you in anticipation!
Bookmarks