如何更改 QTableWidget 标题的背景

问题描述 投票:0回答:0

我可以更改前景色,但不能更改背景色。

我已经尝试过:

    for col in range(self.table.columnCount()):
        item = self.table.horizontalHeaderItem(col)
        item.setForeground(foreground) # foreground changes as expected
        item.setBackground(foreground) # does not affect the background color

和:

    self.table.horizontalHeader().setStyleSheet("color: red; background-color: blue")

如有任何建议,我们将不胜感激

qtablewidget qt6
© www.soinside.com 2019 - 2024. All rights reserved.