#include "widget.h" #include const QString styleStr = " QWidget { " " background: #fafafa; " " color: #000000; " " selection-color: #000000; " " }" " QToolButton { " " border: 1px solid #9e9e9e; " " background: #ffffff; " " padding-top: 2px; " " padding-bottom: 2px; " " } " " QToolButton[popupMode=\"2\"] { " " padding-right: 75px; " " } " " QToolButton::menu-indicator { " " subcontrol-position: right;" " }"; int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setStyleSheet(styleStr); QDialog dlg; dlg.setWindowTitle(QStringLiteral("Qt Version: ") + qVersion()); dlg.setMinimumSize(400, 300); QToolButton *btn = new QToolButton(); btn->setText(QStringLiteral("Menu with text")); btn->setPopupMode(QToolButton::InstantPopup); QMenu *menu = new QMenu(); menu->addAction("Action 1"); menu->addAction("Action 2"); QVBoxLayout *vbox = new QVBoxLayout(&dlg); btn->setMenu(menu); vbox->addWidget(btn); dlg.show(); return a.exec(); }