-
-
Save frueter/f9c71905ffe75e5fc17901e7c1f9f066 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Author
frueter
commented
Sep 24, 2022
via email
Awesome, thank you Keith!
…On Fri, Sep 23, 2022 at 4:56 PM Keith Kyzivat ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
Oh man I'm dating myself.. They moved the Plastique style out of Qt a long
while back I think in the transition from 4.8 to 5.0.
What I think you want to look at is the Fusion style, which is defined
here:
https://github.com/qt/qtbase/blob/dev/src/widgets/styles/qfusionstyle.cpp
You'll want to look at drawPrimitive and drawComplexControl.
Actually, this will have you diving into how the call to drawControl you
make works, which should show what is happening.
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/f9c71905ffe75e5fc17901e7c1f9f066#gistcomment-4312634>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANFIK5JPLEBWH6V74UZQJ3V7U2AJANCNFSM6AAAAAAQMP57OM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment