SARibbon 2.5.1
SARibbon wiki
载入中...
搜索中...
未找到
SARibbonButtonGroupWidget类 参考

用于管理一组Action,类似于QToolBar 更多...

#include <SARibbonButtonGroupWidget.h>

类 SARibbonButtonGroupWidget 继承关系图:
SARibbonQuickAccessBar

Public 成员函数

 SARibbonButtonGroupWidget (QWidget *parent=nullptr)
 
void addMenuAction (QAction *menuAction, QToolButton::ToolButtonPopupMode popupMode=QToolButton::InstantPopup)
 Add a menu QAction to the button group widget/在按钮栏中添加一个带菜单的 QAction
 
QAction * addMenuAction (QMenu *menu, QToolButton::ToolButtonPopupMode popupMode=QToolButton::InstantPopup)
 Create and add a menu action to the button group widget (text only version)/在按钮栏中创建并添加一个带菜单的动作(仅文本版本)
 

详细描述

用于管理一组Action,类似于QToolBar

成员函数说明

◆ addMenuAction() [1/2]

void SARibbonButtonGroupWidget::addMenuAction ( QAction *  menuAction,
QToolButton::ToolButtonPopupMode  popupMode = QToolButton::InstantPopup 
)

Add a menu QAction to the button group widget/在按钮栏中添加一个带菜单的 QAction

This function is used to add a QAction that has been associated with a menu to the toolbar and set its popup mode.The popup mode of the tool button determines how users interact with the menu.

此函数用于向工具栏添加一个已经关联了菜单的 QAction,并设置其弹出模式。工具按钮的弹出模式决定了用户如何与菜单进行交互。

参数
menuActionQAction object that has been set with a menu/已经设置了菜单的 QAction 对象
popupModePopup mode of the tool button, default is InstantPopup/工具按钮的弹出模式,默认为 InstantPopup
注解
If menuAction is not associated with a menu, this function will not perform any special processing/如果 menuAction 没有关联菜单,此函数不会进行任何特殊处理
This function will automatically find the corresponding QToolButton and set the popup mode/此函数会自动查找对应的 QToolButton 并设置弹出模式
Example:/示例:
QMenu *fileMenu = new QMenu("File");
fileMenu->addAction("New");
fileMenu->addAction("Open");
QAction *fileAction = new QAction("File");
fileAction->setMenu(fileMenu);
// Add to button group widget/添加到按钮栏
buttongroup->addMenuAction(fileAction, QToolButton::InstantPopup);
参见
QToolButton::ToolButtonPopupMode

◆ addMenuAction() [2/2]

QAction * SARibbonButtonGroupWidget::addMenuAction ( QMenu *  menu,
QToolButton::ToolButtonPopupMode  popupMode = QToolButton::InstantPopup 
)

Create and add a menu action to the button group widget (text only version)/在按钮栏中创建并添加一个带菜单的动作(仅文本版本)

This function creates a new QAction based on the specified text, associates it with the specified menu, adds it to the toolbar, and sets the popup mode.

此函数根据指定的文本创建一个新的 QAction,将其与指定菜单关联,添加到工具栏并设置弹出模式。

参数
textButton text/按钮文本
menuMenu object to associate/要关联的菜单对象
popupModePopup mode of the tool button, default is InstantPopup/工具按钮的弹出模式,默认为 InstantPopup
返回
Returns the newly created QAction object, or nullptr if the parameter is invalid/返回新创建的 QAction 对象,如果参数无效则返回 nullptr
注解
The caller does not need to manually manage the lifecycle of the returned QAction,it will be automatically managed by the toolbar/调用者不需要手动管理返回的 QAction 的生命周期, 它会由工具栏自动管理
Example:/示例:
// Create menu/创建菜单
QMenu *helpMenu = new QMenu("Help");
helpMenu->addAction("Contents");
helpMenu->addAction("About");
// Add menu to button group widget with custom text/使用自定义文本添加菜单到按钮栏
QAction *helpAction = buttongroup->addMenuAction("Help", helpMenu, QToolButton::MenuButtonPopup);
参见
QToolButton::ToolButtonPopupMode

该类的文档由以下文件生成: