I have a QPushButton and would like to put a red border around it with a certain thickness. What's the best way to do this?
I have a QPushButton and would like to put a red border around it with a certain thickness. What's the best way to do this?
right-click it and then "Change styleSheet...", then you can use css to set border.
try this:
border: 1px solid red;
How would I do it with C++ code?
Hiya,
p_myPushButton = QPushButton("MyButton", p_parent);
p_myPushButton->setStyleSheet("border:5px solid #ff0000;");
That should do it.
Yours,
Matthew.
setStyleSheet() doesn't exist for QPushButton... am I missing something?
I'm sorry, you are correct. My intellisense was messing up and throwing me off! Anyway, it does set the button's border, but it blanks out the button's background. I tried setting it again after the setStyleSheet call but it did not work, presumably because it's being overwritten by the style sheet settings. I understand I could use "background-color" in the style sheet instead, but is that the only way to do it? Thanks.
Bookmarks