While researching Qt.BackgroundRole, I found this list of common roles in the QAbstractItemModel class for different kinds of data and formatting:
Qt.DisplayRole: Data to be rendered as text.
Qt.DecorationRole: Data to be rendered as an icon.
Qt.EditRole: Data that can be edited.
Qt.ToolTipRole: Data to be displayed as a tooltip.
Qt.StatusTipRole: Data to be displayed in a status bar.
Qt.WhatsThisRole: Data that can be used to populate "What's This?" help messages.
Qt.FontRole: Font used to display data.
Qt.TextAlignmentRole: Alignment of the data.
Qt.BackgroundRole: Background color.
Qt.ForegroundRole: Foreground color (e.g., text color).
Qt.CheckStateRole: Check state (e.g., for checkable items).
We could use Qt.TextAlignmentRole instead of a delegate to center the "Scan ID" and "#points" in the table:
if role == Qt.TextAlignmentRole:
if index.column() in [0,4]:
return Qt.AlignCenter
else:
return Qt.AlignLeft
While researching
Qt.BackgroundRole
, I found this list of common roles in theQAbstractItemModel
class for different kinds of data and formatting:Qt.DisplayRole
: Data to be rendered as text.Qt.DecorationRole
: Data to be rendered as an icon.Qt.EditRole
: Data that can be edited.Qt.ToolTipRole
: Data to be displayed as a tooltip.Qt.StatusTipRole
: Data to be displayed in a status bar.Qt.WhatsThisRole
: Data that can be used to populate "What's This?" help messages.Qt.FontRole
: Font used to display data.Qt.TextAlignmentRole
: Alignment of the data.Qt.BackgroundRole
: Background color.Qt.ForegroundRole
: Foreground color (e.g., text color).Qt.CheckStateRole
: Check state (e.g., for checkable items).We could use
Qt.TextAlignmentRole
instead of a delegate to center the "Scan ID" and "#points" in the table:Originally posted by @rodolakis in https://github.com/BCDA-APS/gemviz/issues/157#issuecomment-1706800894