setPalette for QTableWidgetItem in Qt5
-
Is the setPalette option still available for table cells in Qt5?
I am trying to partially fill the background of a table cell. So if cell value is 50 then make cell background half filled with yellow.
-
Is the setPalette option still available for table cells in Qt5?
I am trying to partially fill the background of a table cell. So if cell value is 50 then make cell background half filled with yellow.
@Lobstw
I think not but it has setbrush and it can make gradiants
QRadialGradient gradient(50, 50, 50, 50, 50);
gradient.setColorAt(0, QColor::fromRgbF(0, 1, 0, 1));
gradient.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0));
QBrush brush(gradient); -
@Lobstw
I think not but it has setbrush and it can make gradiants
QRadialGradient gradient(50, 50, 50, 50, 50);
gradient.setColorAt(0, QColor::fromRgbF(0, 1, 0, 1));
gradient.setColorAt(1, QColor::fromRgbF(0, 0, 0, 0));
QBrush brush(gradient);@mrjj I don't think table items have a setbrush. The only set options that I can see are available are: (Background, Checkstate, Data, Flags, Font, Foreground, Icon, Selected, SizeHint, StatusTip, Text, Text Alignment, Tooltip, WhatsThis)
edit: setBackground and setForeground come from QBrush though
-
@mrjj I don't think table items have a setbrush. The only set options that I can see are available are: (Background, Checkstate, Data, Flags, Font, Foreground, Icon, Selected, SizeHint, StatusTip, Text, Text Alignment, Tooltip, WhatsThis)
edit: setBackground and setForeground come from QBrush though
-
@mrjj Hello, setBackground seems to have done the trick, how may I apply it to only a part of the cell instead of the whole thing? Thank you.
-
@Lobstw
Hi
brush is for whole cell, so you have to fake it and make gradiant be normal color in the end
you want to look normal. -
@Lobstw
Yes QRadialGradient is pretty awesome. :)
btw there is also QLinearGradient
http://doc.qt.io/qt-5.5/qgradient.htmljust in case u didnt see them