Python Forum
[PyQt] QTableWidget stylesheet error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[PyQt] QTableWidget stylesheet error
#1
Hi,

I have a QTableWidget on my GUI and when I want to style the table headers, it does not style the top left section of the table.

The table is set-up as follows with the associated style sheet:

def create_table(gui):
    column_size = [100, 260, 150]
    columnLabels = ["A", "B", "C"]

    rowLabels = []
    for i in range(50):
        rowLabels.append(str(i+1))

    gui.table.setFixedWidth(sum(column_size)+34)
    gui.table.setFixedHeight(157)
    gui.table.verticalHeader().setMinimumSectionSize(23)
    gui.table.verticalHeader().setMaximumSectionSize(23)
    gui.table.verticalHeader().setDefaultSectionSize(23)
    gui.table.setHorizontalHeaderLabels(columnLabels)
    gui.table.setVerticalHeaderLabels(rowLabels)
    gui.table.verticalHeader().setVisible(True)
    gui.table.setFont(generalFont)

    cnt = 0
    for column in column_size:
        gui.table.setColumnWidth(cnt, column)
        cnt += 1

    gui.table.setStyleSheet("QHeaderView::section {background-color: rgba(100, 100, 100, 255); color: rgba(200, 200, 200, 255);}")
The headers are correctly styled but the square in the top left corner above the row labels is not styled.
Can someone help me with this?
Reply


Messages In This Thread
QTableWidget stylesheet error - by mart79 - Feb-25-2020, 03:02 PM
RE: QTableWidget stylesheet error - by Denni - Feb-25-2020, 04:16 PM
RE: QTableWidget stylesheet error - by mart79 - Feb-26-2020, 06:45 AM
RE: QTableWidget stylesheet error - by Denni - Feb-26-2020, 04:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyQt] QTreeView, StyleSheet resizes last column malonn 2 1,040 Sep-15-2023, 03:50 PM
Last Post: malonn
  [PyQt] QTableWidget print problem JokerSob 8 4,947 Jan-28-2022, 06:08 PM
Last Post: Axel_Erfurt
  [PyQt] How do I display the DB table I will choose from the QComboBox in QTableWidget JokerSob 2 2,394 Aug-05-2021, 03:00 PM
Last Post: JokerSob
  Displaying database info in QTableWidget thewolf 6 5,512 Apr-03-2021, 02:49 PM
Last Post: thewolf
  [PyQt] Help: check content of combobox in horizontal header of QTableWidget mart79 1 3,468 Jul-26-2020, 06:18 PM
Last Post: deanhystad
  [PyQt] Add validation (regex) to QTableWidget cells mart79 0 2,818 May-05-2020, 12:51 PM
Last Post: mart79
  [PyQt] Pyqt5: How do you make a button that adds new row with data to a Qtablewidget YoshikageKira 6 7,244 Jan-02-2020, 04:32 PM
Last Post: Denni
  [PyQt] QTableWidget cell validation littleGreenDude 1 7,770 Jan-18-2019, 07:44 PM
Last Post: littleGreenDude
  Printing QTableWidget to an DIN A4 page Mady 2 7,317 Dec-18-2018, 06:56 PM
Last Post: Axel_Erfurt
  Cannot Import stylesheet BG? mekha 1 2,326 Aug-08-2018, 04:49 AM
Last Post: mekha

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020