Set CSS in QPushButton's subclass's constructor

心不动则不痛 提交于 2019-12-09 07:39:26

The performance cost of setting a stylesheet is surprisingly high, especially if you're developing for an embedded system.

I'd suggest, like you said, using a global stylesheet and specify the class name, like this:

CustomPushButton { background-color: black; }

this way all CustomPushButton will have the same style, and the object will take less time to create.

As for the reason why it doesn't work in your case, I'd guess maybe your accidentally changing the stylesheet again after the creation of the CustomPushButton.

I tested your code on my side and it worked, so it probably has something to do with code your not showing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!