I have created QLabel *msgLbl. How do I make the msgLbl background semi-transparent?
I have created QLabel *msgLbl . How do I make the msgLbl background semi-transparent?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The easiest way is probably to call
setStylesheet(). If you’re using Qt Designer you can also set the stylesheet from within the designer window (look in the properties bar on the right.You want to set the
background-colorattribute, so something likemsgLbl->setStyleSheet("background-color: rgba(255, 255, 255, 10);");would be the simplest way to do what you describe.
Having said that, you might also want to think about stylesheet inheritance. For example, you might want to set the
background-colorfor a number ofQLabels, all children of a parent widget. You can do that using css-style selectors in a stylesheet set on the parent widget (read this for more information).