The white block on top right corner gets auto added whenever I insert a row.
It selects all rows and columns when I click on it just like in excel
I can see it makes space for S.nos; I've decided it's better to apply style to it rather than delete it .
I want to make it just blend in with the overall table style
You can change the color of the corner through the QTableCornerButton
.
For example with the file t.qss containing :
QTableView QTableCornerButton::section {
background: red;
border: outset red;
}
the code
import sys
from pathlib import Path
from PyQt5.QtWidgets import QApplication, QWidget, QTableWidget
app = QApplication(sys.argv)
root = QWidget()
app.setStyleSheet(Path('t.qss').read_text())
table = QTableWidget(root)
table.setRowCount(2)
table.setColumnCount(2)
table.setGeometry(50 , 50 , 320 , 150)
headerH = ['c1' , 'c2' ]
headerV = ['l1' , 'l2' ]
table.setHorizontalHeaderLabels(headerH)
table.setVerticalHeaderLabels(headerV)
root.show()
sys.exit(app.exec_())
produces :
Of course an external file is not mandatory, and you can also change the style sheet of specifically a given table if you have several, doing for the target table :
table.setStyleSheet('QTableView QTableCornerButton::section{background: red; border: outset red;}')