QT controls add properties and set styles by adding properties
1. Application Scenarios
The application interface is often beautified in QT application programming, and the style sheet QSS is used here. The following approach applies to a type of control that has several unused style styles on the interface, for example, a button with two styles on the interface
2. Set method
Add a custom attribute to the button to which you want to add a style
Select the button, click the + number in the Properties window, add the custom attribute, the attribute is bool type
When the addition is complete, set the style to true, and then hook and choose
You can write this in the style sheet
Qpushbutton[style= "true"]{
background-color:red;
}
So all buttons with the style= "true" attribute have the same style, and the background is red.
Add another Style button to the dynamic property Style1, all buttons with style1= "true" have the same style, background blue
Qpushbutton[style1= "true"]{
Background-color:blue;
}
Code Address: https://download.csdn.net/download/maowendi/10308978
Make a simple record of the application in the project.