实现代码如下所示:
{
QMenu* pMenu = new QMenu(this);
pMenu->addAction(QIcon(":/QRibbonDemo/res/smallpaste.png"), tr("Menu1"));
pMenu->addAction(QIcon(":/QRibbonDemo/res/smallpaste.png"), tr("Menu2"));
pMenu->addAction(QIcon(":/QRibbonDemo/res/smallpaste.png"), tr("Menu3"));
//大按钮
QAction* mainAction = groupClipboard->addAction(QIcon(":/QRibbonDemo/res/largepaste.png"),
tr("&MainAction"), Qt::ToolButtonTextUnderIcon, pMenu);
mainAction->setToolTip(tr("MainAction"));
}
效果如下所示:
点击下测按钮之后: