PushButton spacing with Icon
-
Hello experts,
I am trying to add a pushbutton with a iCon inside that changes on click ( Basically a toggle button behavior.).
I prefer to make the icon taking the complete space of the button, so that it looks like a real switch-button. However some spacing appears in the button (after the icon's boundary) making it look ugly. How can I avoid this spacing of the button .Thanks in advance,
A new-bee of QT -
Hi,
How are you doing it currently ?
How does it show ?
What version of Qt are you using ?
On what OS ? -
Thanks for your reply.
- Currently I am doing similar to below code
QPixmap pixmap("...x.jpg");
QIcon ButtonIcon(pixmap);
button->setIcon(ButtonIcon);
button->setIconSize(pixmap.rect().size()); - It shows the icon however, there are spacing appears in button's boundary ( i.e 3/4 pixels after the icon)
- I am using QT 5.9
- OS: Windows
- Currently I am doing similar to below code
-
@HrishiGobler said in PushButton spacing with Icon:
i.e 3/4 pixels after the icon)
Please be more precise what you mean here - QPushButton draw a border around the icon + some text. If you don't need text you can maybe also go with a QToolButton
-
"QPushButton draw a border around the icon + some text." => Exactly this border is what I mean. Is there any way to avoid this border? I want the icon to completely fit the button without any border
-
"QPushButton draw a border around the icon + some text." => Exactly this border is what I mean. Is there any way to avoid this border? I want the icon to completely fit the button without any border
@HrishiGobler set style sheet to it
setStyleSheet("border: none;");
But it may affect some other styled appearance.