Determining Qt stylesheet options programmatically?

前端 未结 2 701
挽巷
挽巷 2021-01-18 00:25

Is it possible to look up stylesheet values at runtime in Qt?

I\'m working on a custom button derived from QPushButton that has some stylesheet properti

相关标签:
2条回答
  • 2021-01-18 00:43

    Internally, when you call QApplication::setStyleSheet() Qt creates a QStyle sub-class called QStyleSheetStyle.

    That means you can query style sheet information via the normal QStyle methods. Just remember to fill in the options and widget parameters properly to ensure you get the right values from the style sheet.

    0 讨论(0)
  • 2021-01-18 00:52

    Don't think so, you might be able to find something by stepping through the drawing code. But the parsing and the application of stylesheets is pretty optimised and uses a lot of preprocessing. I don't even think that you can get to the stylesheet of a widget if it was actually set in a parent.

    0 讨论(0)
提交回复
热议问题