Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTableWidget set the Background of header Cell
Forum Updated to NodeBB v4.3 + New Features

QTableWidget set the Background of header Cell

Scheduled Pinned Locked Moved General and Desktop
pyqtqtableview
1 Posts 1 Posters 7.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Schiho
    wrote on 13 Oct 2015, 14:53 last edited by Schiho
    #1

    I know how to set the Horizontal Headers background color, but how can i set the Headers Background Color for a specified Row? In this example, say i want to have the Header Row with the Label "3" to be red?

    Example what i get now
    link text

    import sys
    from PyQt4 import QtCore, QtGui
    from PyQt4.QtGui import *
    
    
    
    class Example(QtGui.QWidget):
    
        def __init__(self):
            super(Example, self).__init__()
            self.initUI()
    
    
        def initUI(self):
            self.setGeometry(300, 300, 250, 150)
            self.rigTable = QTableWidget(1, 3, self)
            style = "::section {""background-color: lightblue; }"
            self.rigTable.horizontalHeader().setStyleSheet(style)
            self.rigTable.setShowGrid(False)
    
            self.rigTable.setCellWidget(0, 0, QLabel("A"))
            self.rigTable.setCellWidget(0, 1,  QLabel("B"))      
    
            self.show()
    
    
    def main():
        app = QtGui.QApplication(sys.argv)
        ex = Example()
        sys.exit(app.exec_())
    
    
    if __name__ == '__main__':
        main()
    
    1 Reply Last reply
    0

    1/1

    13 Oct 2015, 14:53

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved