Qt 6.11 is out! See what's new in the release
blog
PyQt6 QTableWidget column padding
-
I'm using the QTableWidget setItemDelegateForColumn method to set the text to be left aligned in a specific column. Is there any way to to also set the padding on the column?
class AlignLeftDelegate(QStyledItemDelegate): def initStyleOption(self, option, index): super(AlignLeftDelegate, self).initStyleOption(option, index) option.displayAlignment = Qt.AlignmentFlag.AlignLeft(I don't want to set the padding in the qss stylesheet code as it will affect all columns )
-
Hi,
One way is to set it as parameter of your custom delegate and re-implement the paint method to take it into account.