I’m trying to set the height of the lines of a table. Namely, I’d like them to be significantly thicker. I’m aware that this can be achieved in the code, but how do I do that with a CSS I feed to the app (e.g., from an external file)?
In the example below, I set the height to a ridiculously large value just to demonstrate that it has no effect. The margin and the padding do, but they move the content of the cells, without changing their size.
import sys
from PySide6.QtWidgets import QApplication, QTableWidget
app = QApplication(sys.argv)
app.setStyleSheet("""
QTableWidget::item { /* or QTableWidget::item::text */
height: 30em;
line-height: 30em;
padding-left: 2em;
margin-top: 1em;
background: green;
}
""")
table = QTableWidget()
table.setRowCount(3)
table.setColumnCount(4)
table.setSizeAdjustPolicy(QTableWidget.SizeAdjustPolicy.AdjustToContents)
table.show()
QApplication.exec()
app.deleteLater() # to ensure the object is still with us
The color is to indicate where the content goes.
The docs I’ve used are the following:
- https://doc.qt.io/qt-6/stylesheet-reference.html
- https://doc.qt.io/qt-6/stylesheet-customizing.html
- https://doc.qt.io/qt-6/stylesheet-examples.html
What have I missed?