Qt controls Add properties and set styles by adding properties __qt

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.