代码之家  ›  专栏  ›  技术社区  ›  jordanthompson

如何更改QTableWidget标题的背景

  •  0
  • jordanthompson  · 技术社区  · 3 年前

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

    我尝试过:

        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")
    

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

    0 回复  |  直到 3 年前
    推荐文章