В примере ниже я установил смехотворно большое значение высоты, просто чтобы продемонстрировать, что это не имеет никакого эффекта. Поля и отступы действуют, но они перемещают содержимое ячеек, не меняя их размера.
Код: Выделить всё
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
Я использовал следующие документы:
[*]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
Что я пропустил?
Подробнее здесь: https://stackoverflow.com/questions/785 ... em-via-css
Мобильная версия