This is a netizen and I talked about the problem, research, is a relatively basic problem, but in the case of handwritten code is easy to ignore.
Q: How do I set a style sheet for a widget in my application that has no effect? This is the method that comes with the QT Help document that applies stylesheet to specific objects, but it doesn't seem to work.
ID Selector
Qpushbutton#okbutton
A: I really did not pay attention to this, a careful try. Find out the answer is included in the instructions you provided. That is, if you want to set the stylesheet of an object in this window individually, be sure to set its ObjectName property. Of course this refers to the case of writing in code, if you use QT Designer, then there is usually a default objectname, it will work. However, it is often difficult to achieve the ideal stylesheet using QT Designer.
Specific examples are as follows:
Qdialog Mydialog;
Mydialog.setobjectname ("Mydialog"); If you want to set stylesheet for this object individually, make sure that it's objectname
And then you can write it like this:
Qdialog#mydialog {background-image:url (2.bmp);