-
-
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) |
Thanks Keith,
yeah, I have no trouble with widgets, just with delegates. I wonder if this
is even supported by stylesheets without manually assigning styles within
the paint method?! Surely it is though.
Take a look at one of the other styles like Plastique and see how they do
things with their Progress Bar delegate.
Where would I find those? Somewhere within the PySide install I assume?!
Cheers,
frank
…On Thu, Sep 15, 2022 at 3:02 AM Keith Kyzivat ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
Ahh.. you use a stylesheet in addition to this, and it's not applying..
It's likely something in your code here that is preventing the stylesheet
from having effect.
Take a look at one of the other styles like Plastique and see how they do
things with their Progress Bar delegate.
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/f9c71905ffe75e5fc17901e7c1f9f066#gistcomment-4301420>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANFIKZWX57KCHUA3PEIBKLV6HSHBANCNFSM6AAAAAAQMP57OM>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
It will be in the C++ sources of Qt. (Sorry, it's not implemented in Python - but it should be reasonably understandable even to someone coming from Python, if they're familiar with the Qt API).
Let me see if I can dig it up.
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.
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
Ahh.. you use a stylesheet in addition to this, and it's not applying.. It's likely something in your code here that is preventing the stylesheet from having effect.
Take a look at one of the other styles like Plastique and see how they do things with their Progress Bar delegate.