Color text in Qtablewidget header

Maurizio Berti maurizio.berti at gmail.com
Thu Jul 4 17:36:00 BST 2024


See the documentation.
https://doc.qt.io/qt-5/stylesheet-reference.html#qheaderview-widget
https://doc.qt.io/qt-5/stylesheet-examples.html#customizing-qheaderview

Note that you may prefer to set a proper QPalette on the tablewidget (or
the window, or the whole app), which would be more accurate, even though it
may not work on some styles.
In any case, consider the following roles:
- Window and Button for "widget background" (scroll bars, header
background, etc.);
- WindowText and ButtonText for the foreground/text color of the above;
- Base for the view's background (and AlternateBase if you use alternate
row colors); it normally is white-ish;
- Text for the view text colors; it normally is dark/black;

Remember that stylesheets are not compatible with custom palettes (they
completely override the widget palette), but *can* be used together with
proper awareness.

Cheers,
Maurizio

Il giorno gio 4 lug 2024 alle ore 18:12 Luca Bertolotti <
luca72.bertolotti at gmail.com> ha scritto:

> Hello i change some colors in my tablewidget in this way:
>  self.tableWidget_2.setStyleSheet(".QTableWidget#tableWidget_2
> {background-color: rgb(0, 0, 0); gridline-color: rgb(255, 255, 255); color:
> rgb(255, 255, 255);}")
>
> there is a way to change the color of the header text because the default
> color is  the one of the main form text (  white because the background
> color is black) so I don't see the header text
>
> I don't know how to change the header color or how to make all the table
> black
>
> Thanks
> Luca
>


-- 
È difficile avere una convinzione precisa quando si parla delle ragioni del
cuore. - "Sostiene Pereira", Antonio Tabucchi
http://www.jidesk.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20240704/284b931b/attachment.htm>


More information about the PyQt mailing list