Currently, I am using a QTableWidget that has alternating colors, however I wanted to alternate the color every other row instead of every row. I made a function for this and it works properly. The problem is, that I still want to use QPalette::AlternateBase and QPalette::Base for the colors.
Currently I can color the brush as follows:
tableNoHighlight.setStyle (Qt::SolidPattern);
tableNoHighlight.setColor(Qt::white);
tableYesHighlight.setStyle (Qt::SolidPattern);
tableYesHighlight.setColor(Qt::lightGray);
QBrush tableNoHighlight;
tableNoHighlight.setStyle (Qt::SolidPattern);
tableNoHighlight.setColor(Qt::white);
QBrush tableYesHighlight;
tableYesHighlight.setStyle (Qt::SolidPattern);
tableYesHighlight.setColor(Qt::lightGray);
To copy to clipboard, switch view to plain text mode
However, since the colors are hard set, the highlighting does not match the particular look and feel of the OS that the program might be run in. Thus I wanted to use QPalette::AlternateBase and QPalette::Base.
I tried the following:
tableNoHighlight = QPalette::brush(QPalette::AlternateBase);
tableNoHighlight = QPalette::brush(QPalette::Base);
To copy to clipboard, switch view to plain text mode
and I got this error:
alculatorform.cpp:81: error: cannot call member function `const QBrush& QPalette::brush(QPalette::ColorRole) const' without object
alculatorform.cpp:87: error: cannot call member function `const QBrush& QPalette::brush(QPalette::ColorRole) const' without object
so I tried:
tableNoHighlight
= this
->brush
(QPalette::AlternateBase);
tableNoHighlight
= this
->brush
(QPalette::Base);
tableNoHighlight = this->brush(QPalette::AlternateBase);
tableNoHighlight = this->brush(QPalette::Base);
To copy to clipboard, switch view to plain text mode
and
tableNoHighlight
= ui
->brush
(QPalette::AlternateBase);
tableNoHighlight
= ui
->brush
(QPalette::Base);
tableNoHighlight = ui->brush(QPalette::AlternateBase);
tableNoHighlight = ui->brush(QPalette::Base);
To copy to clipboard, switch view to plain text mode
and both yielded errors about having no member named brush.
How can I get the brush of QPalette::AlternateBase and QPalette::Base (or at least the color value) to use elsewhere?
Bookmarks