PushButton icon spacing
Unsolved
QML and Qt Quick
-
Hi Experts! i have a trouble to set spacing between icon and text in QPushButton. I tried to edit the styling with
qproperty-iconSpacing
, but it doesn't work. Here's the example of my code :#include "buttonSidebarActive.h" #include "../resources/iconPaths.h" #include "../styles/colors.h" #include "../styles/textStyle.h" #include <qboxlayout.h> #include <qstyle.h> ButtonSidebarActive::ButtonSidebarActive(const QString &iconType, const QString &buttonLabel, QWidget *parent) : QPushButton(buttonLabel, parent) { QBoxLayout *layout = new QBoxLayout(QBoxLayout::LeftToRight, this); QString iconPath = IconPaths::getIconPath(iconType); setIcon(QIcon(iconPath)); setIconSize(QSize(40, 40)); setStyleSheet("QPushButton {" " padding: 12px 8px;" " text-align: left;" " border: 0 solid;" " border-radius: 12px;" " background-color:" + Colors::Secondary500.name() + ";" " color: " + Colors::StandardWhite.name() + ";" " " + TextStyle::BodyBigBold() + "}" "QPushButton:hover {" " background-color: " + Colors::Secondary300.name() + ";" "}" "QPushButton:pressed {" " background-color: " + Colors::Primary600.name() + ";" "}" "QPushButton:disabled {" " border-color: " + Colors::Grey400.name() + ";" " color: " + Colors::Grey400.name() + ";" "}"); }