Change button pressed color without adding a border to the button
-
I am using PyQT and have a button that, when pressed, I want it to change colors but I also want to remove the border. I was able to accomplish both of these, but not at the same time.
I remove the border using
self.ui.button_name.setStyleSheet("border: 0px;")
And then I change the pressed function using
self.ui.button_name.setStyleSheet("QPushButton:pressed {background-color: #BDBCBD};")
When both are used together, the button does change color but then a rectangle is added around it. How can I both, remove the border and change the color when pressed?
-
S SGaist moved this topic from General and Desktop on
-
Hi,
You should set all as a single stylesheet. What you do, from your description, is replace the first with the second.
-
Hi,
You should set all as a single stylesheet. What you do, from your description, is replace the first with the second.
@SGaist When I put them together nothing changes. I still have the grey rectangle around the button
self.ui.button_name.setStyleSheet("QPushButton:pressed {background-color: #BDBCBD}; border: 0px;")
-
Can you provide a minimal complete example to check what is happening ?