PDA

View Full Version : How do I get elements of a base widget?



Nfrancisj
30th May 2017, 21:30
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.

12486

d_stranz
31st May 2017, 00:35
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.

Nfrancisj
31st May 2017, 00:57
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!

Nfrancisj
31st May 2017, 03:59
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!

d_stranz
31st May 2017, 17:16
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.