PDA

View Full Version : Style sheet related question



chandan
7th May 2010, 14:20
Hi everyone,
I am developing a User Interface where I have used style sheet for QLabel, QPushButton etc. For this I have created the qss files and then stored the style sheet information there. But the problem is I am using several QPushButton qss files to use them for different type of push buttons. Some of them have large text, some of them have different background and some of them have rounded edge. So now my question is, Is there any way to use the same qss file for these different types of QPushButton ? I mean can I use any logic in qss file so that it can dynamically change the style according to the button this file is called for?
Thanks in advance.
Pritimoy

chandan
7th May 2010, 15:51
Hi everyone,
I got the answer. If you have a number of buttons with different features then you can use a single qss file to maintain the style sheet for all those. For that you have to use the following code;


QPushButton[text = 'OK'] {
color: green;
}

QPushButton[text = 'Cancel'] {
color: blue;
}


Here in place of text you can use any unique feature or you can use the name of the object to show them in different styles.

Hope this will help others.