QToolButton* button = new QToolButton(parent); QMenu* menu = new QMenu(button); menu->addAction("Option 1"); menu->addAction("Option 2"); menu->addAction("Option 3"); button->setMenu(menu);
QToolButton* button = new QToolButton(parent); button->setIcon(QIcon(":/images/icon.png")); button->setAutoRaise(true); button->setPopupMode(QToolButton::InstantPopup); QMenu* menu = new QMenu(button); menu->addAction("Option 1"); menu->addAction("Option 2"); menu->addAction("Option 3"); button->setMenu(menu);
QToolButton* button = new QToolButton(parent); button->setIcon(QIcon(":/images/button.png")); button->setStyleSheet("QToolButton::menu-indicator { image: url(:/images/arrow.png); }"); QMenu* menu = new QMenu(button); menu->addAction("Option 1"); menu->addAction("Option 2"); menu->addAction("Option 3"); button->setMenu(menu);This creates a QToolButton with an icon, and sets a custom style sheet to change the menu arrow icon to a different image. Package/library: Qt.