Hi,
I applied style sheet on widget with different object name.I m changing object name of widget at run time,but stylesheet corresponding to new object name doesnot reflect on widget.I also tried update(),but no use
Please suggest
Hi,
I applied style sheet on widget with different object name.I m changing object name of widget at run time,but stylesheet corresponding to new object name doesnot reflect on widget.I also tried update(),but no use
Please suggest
I suggest you provide some actual information on what you have done, what you expected to see, and what you actually saw. All we know is that you applied style sheet to a widget.
Hi,
I attached a sample program in which i m try to change stylesheet of widget by changing object name on clicking the button.
Please see the code and let me know where am i woring
Thanks
Stylesheets are not reevaluated when properties of widgets change. The only way to force reevaluation is to reapply the stylesheet. However changing object names in the middle of the program is probably not a good thing to do in general.
I have constraint to apply stylesheet only once in my project. Can u suggest other good and proper way to solve my problem.
Please suggest any alternative?
I don't know what you are trying to do so it is hard to suggest an alternative. Subclassing QStyle is a likely solution however changing an object property will still not trigger a redraw automatically. If you are using stylesheets then reapplying the stylesheet seems the best option.
Yes. Do it from your program. Apply the effects first then when the desired button is clicked, override its click event and in that change the effects of the widget again.
This way you will even not need to change the object name of the widget from inside the program.
after changing object name just call setStyleSheet("")
Qt Code:
label->setObjectName("errorLabel"); label->setStyleSheet("");To copy to clipboard, switch view to plain text mode
this will update stylesheet for this widget![]()
Bookmarks