Reputation: 374
In the constructor, I set the style for the form and buttons:
{
ui->setupUi(this);
this->setStyleSheet("QWidget {background: rgb(49, 54, 59); color: rgb(220, 221, 218); selection-color: lightyellow; selection-background-color: darkcyan;}"
"QPushButton::hover {color: darkcyan; border: 2px solid grey; border-radius: 3px};");
}
Next, in the properties (icon
parameter) of the button, I added an icon
via resources, I also set the icon size using the iconSize
parameter - 20x20
, I also set the flat
- True
parameter in.
And this is what I get when I hover the cursor over the button:
The size of the button itself is formed using the layout and the size
is 32x26
, when the picture is set to 20x20
.
Please tell me how you can remove this gap
between the picture
and the border
of the button?
I tried to set the button size statically, about 22x22
and then everything is more or less fine, but I don't want to resort to such a radical solution. Thanks.
Upvotes: 0
Views: 354
Reputation: 1735
Referring to Qt's box model, the gap between the border and the icon is the padding.
In the stylesheet, you can set the padding to 0 as followed padding: 0px;
Upvotes: 1