1 Attachment(s)
How do I get elements of a base widget?
Hiya,
I have this timeline from Nuke, and I would like to style the ticks and numbers individually.
I have the object (QWidget), that is the timeline, but I can't figure out how to get its elements (the ticks and numbers).
I am able to style all the elements together, but I want to know how to dig deeper and style each element. I can't use .children() because it seems to be the very bottom of the group.
I assume I now need to use the stylesheet selector tag to get the elements. How would I go about identifying the elements to use the selector.
Please see attached image.
Attachment 12486
Re: How do I get elements of a base widget?
If it is a typical custom widget, it is probably "hand-drawn" in its paintEvent() and you can't get to any sub-elements because there aren't any. Stylesheets are optional, too. If the widget supports them, then you can use QWidget::styleSheet() to get the QString representation of the style sheet and see if there are any recognizable elements in it.
Re: How do I get elements of a base widget?
THAT IS PERFECT! I was looking for .stylesheet() for a very very long time. hahaha! I've used setStyleSheet so many times, I never thought to look at the docs for .styleSheet()
Thanks Dude!
Re: How do I get elements of a base widget?
Quote:
probably "hand-drawn" in its paintEvent()
Diving deeper, I must confess I haven't reached the QGraphics chapter yet, is there anyway to explore Paint Elements? I assume paintEvents paint QGraphics Scene and Items, ya?
So a standard QPushButton is constructed using the QGraphics family of classes and it's painted using a paintEvent? Is there a way to dive down into that and see what constructs the QPushButton?
Thanks a lot, I really am learning a lot. ðŸ˜
Cheers!
Re: How do I get elements of a base widget?
Quote:
So a standard QPushButton is constructed using the QGraphics family of classes and it's painted using a paintEvent?
Yes, it is drawn using a paintEvent() (as are all QWidget-based classes), but no, as far as I know it is drawn using platform-specific QStyle ControlElement and SubElement types because it is not based on QGraphicsItem.