QMenu* menu1 = new QMenu;
QAction *action1 = new QAction("action1", this);
QAction* action2 = new QAction("action2", this);
QAction* action3 = new QAction("action3", this);
QAction* action4 = new QAction("action4", this);
menu1->addAction(action1);
menu1->addAction(action2);
menu1->addAction(action3);
menu1->addAction(action4);
ui.toolButton->setMenu(menu1);
ui.toolButton->setPopupMode(QToolButton::MenuButtonPopup);
搜一下介绍这个几乎没有,就记录一下。按钮与菜单事件都是分开处理的