Вы должны проверить QAction или использовать QWidget, который можно проверить, например, QToolButton:
#include <QtWidgets>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMainWindow w;
QToolBar *toolbar = w.addToolBar("Toolbar");
QAction *bold_action = toolbar->addAction("B");
QFont bold_fn(bold_action->font());
bold_fn.setBold(true);
bold_action->setFont(bold_fn);
bold_action->setCheckable(true);
QAction *italic_action = toolbar->addAction("I");
QFont fn_cursive(italic_action->font());
fn_cursive.setItalic(true);
italic_action->setFont(fn_cursive);
italic_action->setCheckable(true);
QAction *underline_action = toolbar->addAction("U");
QFont fn_underline(underline_action->font());
fn_underline.setUnderline(true);
underline_action->setFont(fn_underline);
underline_action->setCheckable(true);
QAction* subscript_action = new QAction;
subscript_action->setIcon(QIcon(":/subscript.png"));
subscript_action->setCheckable(true); // <---
toolbar->addAction(subscript_action);
w.setCentralWidget(new QTextEdit);
w.resize(320, 240);
w.show();
return a.exec();
}
Выход: