本文介绍了以编程方式确定Qt样式表选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在运行时在Qt中查找样式表值?

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

我正在使用一个来自QPushButton的自定义按钮,它有一些样式表属性设置。我想能够查找一些样式表设置,如边框宽度,边距,padding-top,padding-left,padding-right等。这是可能的,没有调用widget-> getStyleSheet()和解析。

I'm working on a custom button derived from QPushButton that has some stylesheet properties set. I'd like to be able to look up some stylesheet settings like border width, margin, padding-top, padding-left, padding-right, etc. Is this at all possible to do without calling widget->getStyleSheet() and parsing out the values myself?

推荐答案

不要这样,你可以通过绘制代码来找到一些东西。但是解析和样式表的应用程序是非常优化的,并且使用了很多预处理。我甚至不认为你可以获得一个小部件的样式表,如果它实际上设置在父级。

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.

这篇关于以编程方式确定Qt样式表选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-19 19:21