QAbstractButton* MainWindow::createIconButton(const QString &iconPath, const QString &text, QWidget *parent) const { QCheckBox *button = new QCheckBox(text, parent); //button->setIcon(QIcon(iconPath)); button->setStyleSheet("QCheckBox::indicator { image: url(" + iconPath.arg("") + "); }" "QCheckBox::indicator:hover { image: url(" + iconPath.arg("_hovered") + "); }" "QCheckBox::indicator:pressed { image: url(" + iconPath.arg("_pressed") + "); }"); button->setIconSize(QImage(iconPath).size()); button->setContentsMargins(0, 0, 0, 0); button->setCursor(Qt::PointingHandCursor); button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); return button; }