PyQt Designer: How to make a button's edges rounder?

13,064

You can get the effect you want by setting the radius of the border in the stylesheet, like so:

border-radius: 15px

Edit: I guess I spoke to soon. I tried it out myself and it does not have the desired effect when you have set a background color. There is some other weird stuff that happens when you change the color; it removes some other default styling that you will need to add back in manually if you want it to look similar to how it did before.

Try adding the following into the QPushButton's stylesheet, and play around with the numbers to see how they affect the button:

background-color: orange;
border-style: outset;
border-width: 2px;
border-radius: 15px;
border-color: black;
padding: 4px;

You may also need to set up some style changes for when the button is pushed (e.g. change the border-style to inset on pressed)

Share:
13,064
Diogo Magalhães
Author by

Diogo Magalhães

Updated on June 04, 2022

Comments

  • Diogo Magalhães
    Diogo Magalhães almost 2 years

    In PyQt's designer tool, when you create a QPushButton, at first, it will look like this: pic 1

    If you right-click on it, pick 'Change stylesheet' and change the button background color to orange, for example, you'll get this:

    pic 2

    If you notice, the button's shape changed slightly, it's edges became more sharp and even the 'click' makes it look more 'squared' and I don't want that. I want it to look like before but just with the background set to orange. Is this possible? As an alternative, is there a way so make the edges rounder?

    Thank you.