RibbonGroup添加QAction

实际项目中,group中需要添加按钮与点击事件:

添加实例如下:

if (Qtitan::RibbonGroup* groupClipboard = pageHome->addGroup(tr("Clipboard")))
        {
            //右下角按钮显示
            groupClipboard->setOptionButtonVisible();
            QAction* act = groupClipboard->getOptionButtonAction();
            act->setText(tr("Clipboard"));
            act->setToolTip(tr("Show the Office clipboard Task Pane"));
            act->setStatusTip(tr("Show the Office clipboard Task Pane"));
            connect(act, SIGNAL(triggered()), this, SLOT(optionClipboard()));

            QAction*  pactionPaste = groupClipboard->addAction(QIcon(":/QRibbonDemo/res/largeThemes.png"),
                tr("&Paste"), Qt::ToolButtonTextUnderIcon);
            pactionPaste->setToolTip(tr("Paste Click"));
            connect(pactionPaste, SIGNAL(triggered()), this, SLOT(optionPaste()));
        }

响应事件:

protected slots:
    void optionPaste();

void QRibbonDemo::optionPaste()
{
    QMessageBox messageBox(QMessageBox::Information, windowTitle(),
        QLatin1String(""), QMessageBox::Ok, this);
    messageBox.setInformativeText(QLatin1String("Paste"));
    messageBox.exec();
}

RibbonGroup添加QAction_第1张图片

效果如下所示:

RibbonGroup添加QAction_第2张图片

RibbonGroup添加QAction_第3张图片

你可能感兴趣的:(QT,c++,QAction,ToolButton,RibbonGroup,Ribbon)