tpf80
16th July 2007, 23:42
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:
QBrush tableNoHighlight;
tableNoHighlight.setStyle (Qt::SolidPattern);
tableNoHighlight.setColor(Qt::white);
QBrush tableYesHighlight;
tableYesHighlight.setStyle (Qt::SolidPattern);
tableYesHighlight.setColor(Qt::lightGray);
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);
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);
and
tableNoHighlight = ui->brush(QPalette::AlternateBase);
tableNoHighlight = ui->brush(QPalette::Base);
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?
Currently I can color the brush as follows:
QBrush tableNoHighlight;
tableNoHighlight.setStyle (Qt::SolidPattern);
tableNoHighlight.setColor(Qt::white);
QBrush tableYesHighlight;
tableYesHighlight.setStyle (Qt::SolidPattern);
tableYesHighlight.setColor(Qt::lightGray);
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);
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);
and
tableNoHighlight = ui->brush(QPalette::AlternateBase);
tableNoHighlight = ui->brush(QPalette::Base);
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?