Defining Qt program tables programmatically?

Is it possible to search for style values ​​at runtime in Qt?

I am working on a custom button derived from QPushButton that has some stylesheet properties. I would like to be able to look for some style sheet settings such as border width, margin , padding-top , padding-left , padding-right , etc. Is it possible to do without calling widget->getStyleSheet() and parsing the values ​​themselves?

+8
c ++ qt qss
source share
2 answers

Do not think so, you can find something by going through the drawing code. But parsing and applying style sheets are pretty optimized and use a lot of preprocessing. I don’t even think that you can get into the widget stylesheet if it was really installed in the parent.

+3
source share

Internally, when you call QApplication :: setStyleSheet (), Qt creates a subclass of QStyle called QStyleSheetStyle.

This means that you can query style sheet information using the usual QStyle methods. Do not forget to correctly fill in the parameters and parameters of the widget to make sure that you get the correct values ​​from the stylesheet.

+5
source share

Source: https://habr.com/ru/post/650106/


All Articles