Skip to content

Instantly share code, notes, and snippets.

@frueter
Created September 14, 2022 06:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frueter/f9c71905ffe75e5fc17901e7c1f9f066 to your computer and use it in GitHub Desktop.
Save frueter/f9c71905ffe75e5fc17901e7c1f9f066 to your computer and use it in GitHub Desktop.
class PBarDelegate(QtWidgets.QStyledItemDelegate):
def paint(self, painter, option, index):
progress_bar_option = QtWidgets.QStyleOptionProgressBar()
progress_bar_option.rect = option.rect
progress_bar_option.state = QtWidgets.QStyle.State_Enabled
progress_bar_option.direction = QtCore.Qt.LayoutDirection.LeftToRight
progress_bar_option.fontMetrics = QtWidgets.QApplication.fontMetrics()
progress_bar_option.minimum = 0
progress_bar_option.maximum = 100
progress_bar_option.textAlignment = QtCore.Qt.AlignCenter
progress_bar_option.textVisible = True
# set progress and text:
data = index.data(QtCore.Qt.UserRole)
if data:
progress_bar_option.progress = data
progress_bar_option.text = index.data(QtCore.Qt.DisplayRole)
QtWidgets.QApplication.style().drawControl(QtWidgets.QStyle.CE_ProgressBar,
progress_bar_option, painter)
@frueter
Copy link
Author

frueter commented Sep 24, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment