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

panel页窗口,panel是ribbon的面板用于承放控件 / Ribbon panel container, used to hold controls 更多...

#include <SARibbonPanel.h>

类 SARibbonPanel 继承关系图:

class  PrivateData
 

Public 类型

enum  PanelLayoutMode { ThreeRowMode , TwoRowMode }
 Layout mode for the panel / 面板的布局模式 更多...
 
using FpRibbonToolButtonIterate = std::function< bool(SARibbonToolButton *) >
 

信号

void actionTriggered (QAction *action)
 等同于QToolBar::actionTriggered
 
void panelNameChanged (const QString &n)
 Emitted when the panel's name changes / 当面板名称改变时发出
 

Public 成员函数

 SARibbonPanel (QWidget *parent=nullptr)
 Constructs a SARibbonPanel with the given parent / 使用给定的父对象构造SARibbonPanel
 
 SARibbonPanel (const QString &name, QWidget *parent=nullptr)
 Constructs a SARibbonPanel with a name and the given parent / 使用名称和给定的父对象构造SARibbonPanel
 
void addAction (QAction *action, SARibbonPanelItem::RowProportion rowProportion)
 Adds an action to the panel / 向面板添加一个action
 
void addAction (QAction *act, QToolButton::ToolButtonPopupMode popMode, SARibbonPanelItem::RowProportion rowProportion=SARibbonPanelItem::Large)
 Adds an action with a specified popup mode / 添加一个具有指定弹出模式的action
 
void addLargeAction (QAction *action)
 Adds a large action (occupies full height) / 添加一个大action(占据整个高度)
 
void addMediumAction (QAction *action)
 Adds a medium action / 添加一个中等action
 
void addSmallAction (QAction *action)
 Adds a small action / 添加一个小action
 
void addSmallAction (QAction *action, QToolButton::ToolButtonPopupMode popMode)
 Adds a small action with a specified popup mode / 添加一个具有指定弹出模式的小action
 
void addLargeAction (QAction *action, QToolButton::ToolButtonPopupMode popMode)
 Adds a large action with a specified popup mode / 添加一个具有指定弹出模式的大action
 
void addMediumAction (QAction *action, QToolButton::ToolButtonPopupMode popMode)
 Adds a medium action with a specified popup mode / 添加一个具有指定弹出模式的中等action
 
QAction * addAction (const QString &text, const QIcon &icon, QToolButton::ToolButtonPopupMode popMode, SARibbonPanelItem::RowProportion rowProportion=SARibbonPanelItem::Large)
 Creates and adds a new action / 创建并添加一个新的action
 
void addMenu (QMenu *menu, SARibbonPanelItem::RowProportion rowProportion, QToolButton::ToolButtonPopupMode popMode=QToolButton::InstantPopup)
 Adds a menu to the panel / 向面板添加一个菜单
 
void addLargeMenu (QMenu *menu, QToolButton::ToolButtonPopupMode popMode=QToolButton::InstantPopup)
 Adds a menu as a large button / 以大按钮形式添加一个菜单
 
void addMediumMenu (QMenu *menu, QToolButton::ToolButtonPopupMode popMode=QToolButton::InstantPopup)
 Adds a menu as a medium button / 以中按钮形式添加一个菜单
 
void addSmallMenu (QMenu *menu, QToolButton::ToolButtonPopupMode popMode=QToolButton::InstantPopup)
 Adds a menu as a small button / 以小按钮形式添加一个菜单
 
QAction * addWidget (QWidget *w, SARibbonPanelItem::RowProportion rowProportion)
 Adds a custom widget to the panel / 向面板添加一个自定义窗口部件
 
QAction * addSmallWidget (QWidget *w)
 Adds a widget as a small button / 以小按钮形式添加一个窗口部件
 
QAction * addMediumWidget (QWidget *w)
 Adds a widget as a medium button / 以中等按钮形式添加一个窗口部件
 
QAction * addLargeWidget (QWidget *w)
 Adds a widget as a large button / 以大按钮形式添加一个窗口部件
 
SARibbonGalleryaddGallery (bool expanding=true)
 Adds a gallery widget to the panel / 向面板添加一个画廊窗口部件
 
QAction * addSeparator ()
 Adds a separator / 添加一个分隔符
 
SARibbonToolButtonactionToRibbonToolButton (QAction *action)
 Retrieves the SARibbonToolButton associated with an action / 获取与action关联的SARibbonToolButton
 
void setOptionAction (QAction *action)
 Sets the option action for the panel / 为面板设置选项action
 
bool isHaveOptionAction () const
 Checks if an option action is set / 检查是否设置了选项action
 
QList< SARibbonToolButton * > ribbonToolButtons () const
 Returns a list of all SARibbonToolButton children / 返回所有SARibbonToolButton子对象的列表
 
PanelLayoutMode panelLayoutMode () const
 Gets the current layout mode / 获取当前的布局模式
 
void setPanelLayoutMode (PanelLayoutMode mode)
 Sets the panel's layout mode / 设置面板的布局模式
 
void resetToolButtonSize ()
 重置按钮的尺寸,在布局改变后(尤其高度变更),按钮的尺寸需要手动变更
 
bool isTwoRow () const
 
void setExpanding (bool isExpanding=true)
 Sets the panel to expanding mode / 将面板设置为扩展模式
 
bool isExpanding () const
 Checks if the panel is in expanding mode / 检查面板是否处于扩展模式
 
int titleHeight () const
 Gets the height of the panel's title / 获取面板标题的高度
 
bool isEnableShowTitle () const
 Checks if the panel's title is visible / 检查面板标题是否可见
 
int actionIndex (QAction *act) const
 Gets the index of an action within the panel / 获取一个action在面板内的索引
 
void moveAction (int from, int to)
 Moves an action to a new position / 将一个action移动到新位置
 
bool isCanCustomize () const
 Checks if customization is allowed / 检查是否允许自定义
 
void setCanCustomize (bool b)
 Sets whether customization is allowed / 设置是否允许自定义
 
QString panelName () const
 Gets the panel's name / 获取面板的名称
 
void setPanelName (const QString &title)
 Sets the panel's name / 设置面板的名称
 
int largeButtonHeight () const
 Gets the height of the large buttons in this panel / 获取此面板中大按钮的高度
 
const QList< SARibbonPanelItem * > & ribbonPanelItem () const
 获取布局item
 
SARibbonPanelLayoutpanelLayout () const
 Gets the panel's layout object / 获取面板的布局对象
 
void updateItemGeometry ()
 Updates the geometry of all items in the panel / 更新面板内所有项目的几何形状
 
SARibbonCategorycategory () const
 Gets the parent SARibbonCategory / 获取父SARibbonCategory
 
SARibbonBarribbonBar () const
 Gets the top-level SARibbonBar / 获取顶层的SARibbonBar
 
int spacing () const
 Gets the spacing between elements in the panel / 获取面板内元素之间的间距
 
void setToolButtonIconSize (const QSize &s)
 Sets the icon size for all tool buttons in the panel / 设置面板内所有工具按钮的图标尺寸
 
QSize toolButtonIconSize () const
 Gets the current default icon size for tool buttons / 获取工具按钮当前的默认图标尺寸
 
SARibbonToolButtonlastAddActionButton ()
 获取最近添加的按钮
 
SARibbonPanelLabeltitleLabel () const
 Gets the title label widget / 获取标题标签窗口部件
 
bool isEnableWordWrap () const
 判断panel的文字是否允许换行
 
qreal buttonMaximumAspectRatio () const
 按钮最大宽高比,这个系数决定按钮的最大宽度
 
bool iterateButton (FpRibbonToolButtonIterate fp) const
 Iterates over all SARibbonToolButton children / 遍历所有SARibbonToolButton子对象
 
virtual QSize sizeHint () const Q_DECL_OVERRIDE
 
virtual QSize minimumSizeHint () const Q_DECL_OVERRIDE
 

静态 Public 成员函数

static int panelHeightHint (const QFontMetrics &fm, PanelLayoutMode layMode, int panelTitleHeight)
 Gets the panel's recommended height / 获取面板的推荐高度
 
static void setActionRowProportionProperty (QAction *action, SARibbonPanelItem::RowProportion rp)
 Sets the row proportion property for an action / 为一个action设置行占比属性
 
static SARibbonPanelItem::RowProportion getActionRowProportionProperty (QAction *action)
 Gets the row proportion property from an action / 从一个action获取行占比属性
 
static void setActionToolButtonPopupModeProperty (QAction *action, QToolButton::ToolButtonPopupMode popMode)
 Sets the ToolButtonPopupMode property for an action / 为一个action设置ToolButtonPopupMode属性
 
static QToolButton::ToolButtonPopupMode getActionToolButtonPopupModeProperty (QAction *action)
 Gets the ToolButtonPopupMode property from an action / 从一个action获取ToolButtonPopupMode属性
 
static void setActionToolButtonStyleProperty (QAction *action, Qt::ToolButtonStyle buttonStyle)
 Sets the ToolButtonStyle property for an action / 为一个action设置ToolButtonStyle属性
 
static Qt::ToolButtonStyle getActionToolButtonStyleProperty (QAction *action)
 Gets the ToolButtonStyle property from an action / 从一个action获取ToolButtonStyle属性
 

Protected 成员函数

virtual void actionEvent (QActionEvent *e) Q_DECL_OVERRIDE
 Handles action events (add, remove, change) / 处理action事件(添加、移除、更改)
 
virtual void changeEvent (QEvent *e) Q_DECL_OVERRIDE
 Handles change events (e.g., font change) / 处理更改事件(例如,字体更改)
 
void setTitleHeight (int h)
 Sets the height of the panel's title / 设置面板标题的高度
 
void setSpacing (int n)
 Sets the spacing between elements in the panel / 设置面板内元素之间的间距
 
void setEnableShowTitle (bool on)
 Sets whether the panel's title is visible / 设置面板标题是否可见
 
void setEnableWordWrap (bool on)
 设置panel的按钮文字允许换行
 
void setButtonMaximumAspectRatio (qreal fac=1.4)
 设置按钮最大宽高比,这个系数决定按钮的最大宽度
 

属性

bool isCanCustomize
 
bool isExpanding
 
QString panelName
 

友元

class SARibbonBar
 
class SARibbonCategory
 
class SARibbonCategoryPrivate
 
class SARibbonCustomizeWidgetPrivate
 
class SARibbonPanelLayout
 

详细描述

panel页窗口,panel是ribbon的面板用于承放控件 / Ribbon panel container, used to hold controls

The SARibbonPanel is a core component of the Ribbon interface. It acts as a container for QAction objects, automatically creating and managing SARibbonToolButton instances based on the specified layout proportion (Large, Medium, Small). It supports dynamic layout modes (ThreeRowMode, TwoRowMode) and can display an optional title and an option button.

SARibbonPanel 是 Ribbon 界面的核心组件之一。它作为 QAction 对象的容器, 根据指定的布局比例(大、中、小)自动创建和管理 SARibbonToolButton 实例。 它支持动态布局模式(三行模式、两行模式),并可显示可选的标题和选项按钮。


布局模式 / Layout Modes

The panel has two layout modes: two-row and three-row.

  • ThreeRowMode: The Ribbon in Microsoft Office is a representative.
  • TwoRowMode: The "compact style" represented by WPS. You can specify the mode via SARibbonBar::RibbonStyle (using SARibbonBar::setRibbonStyle).

ribbon的panel分为两行模式和三行模式。

  • 三行模式: 以 Microsoft Office 为代表。
  • 两行模式: 以 WPS 为代表的“紧凑派”。 可通过 SARibbonBar::RibbonStyle (使用 SARibbonBar::setRibbonStyle 函数) 来指定模式。

扩展模式 / Expanding Mode

Within a panel, you can use setExpanding to specify horizontal expansion. Recommendation: Only use this if the panel contains expandable widgets (e.g., SARibbonGallery). Otherwise, blank space will be left.

在panel中,可以通过setExpanding 函数指定panel水平扩展。 建议: 仅在面板内包含可扩展控件(如 SARibbonGallery)时使用此函数。 否则,将会留白。


自定义布局 / Custom Layout

The panel's layout is implemented by SARibbonPanelLayout. To use a custom layout, inherit from SARibbonElementCreateDelegate::createRibbonPanel.

panel的布局通过SARibbonPanelLayout 来实现。 如需自定义布局,请继承 SARibbonElementCreateDelegate::createRibbonPanel 函数。


全局属性设置 / Global Property Settings

SARibbonPanel is a child of SARibbonCategory, which belongs to SARibbonBar. Important: Setting properties directly on a standalone SARibbonPanel is often meaningless. Global properties (like title height, spacing) are managed by SARibbonBar. Use these functions in SARibbonBar instead:

  • panelTitleHeight
  • isEnableShowPanelTitle
  • panelSpacing
  • panelToolButtonIconSize

SARibbonPanel属于SARibbonCategory的子对象,SARibbonCategory又属于SARibbonBar的对象。 重要: 单独设置一个SARibbonPanel的属性很多情况是没有意义的。 全局性属性(如标题高度、间距)由SARibbonBar统一管理。 请改用SARibbonBar中的以下函数:

  • panelTitleHeight
  • isEnableShowPanelTitle
  • panelSpacing
  • panelToolButtonIconSize

成员枚举类型说明

◆ PanelLayoutMode

Layout mode for the panel / 面板的布局模式

枚举值
ThreeRowMode 

Three-row layout mode / 三行布局模式

In this mode, small buttons are arranged in three rows, while medium buttons occupy two rows. Large buttons always occupy the full height.

在此模式下,小按钮排列成三行,中等按钮占据两行。 大按钮始终占据整个高度。

TwoRowMode 

Two-row layout mode / 两行布局模式

In this mode, both small and medium buttons are arranged in two rows. Large buttons always occupy the full height.

在此模式下,小按钮和中等按钮都排列成两行。 大按钮始终占据整个高度。

构造及析构函数说明

◆ SARibbonPanel() [1/2]

SARibbonPanel::SARibbonPanel ( QWidget *  parent = nullptr)
explicit

Constructs a SARibbonPanel with the given parent / 使用给定的父对象构造SARibbonPanel

参数
parentThe parent widget / 父窗口部件

◆ SARibbonPanel() [2/2]

SARibbonPanel::SARibbonPanel ( const QString &  name,
QWidget *  parent = nullptr 
)
explicit

Constructs a SARibbonPanel with a name and the given parent / 使用名称和给定的父对象构造SARibbonPanel

参数
nameThe panel's display name / 面板的显示名称
parentThe parent widget / 父窗口部件

成员函数说明

◆ actionEvent()

void SARibbonPanel::actionEvent ( QActionEvent *  e)
protectedvirtual

Handles action events (add, remove, change) / 处理action事件(添加、移除、更改)

This function is called by Qt when actions are added, removed, or changed. It ensures the panel's layout is updated accordingly.

当action被添加、移除或更改时,Qt会调用此函数。它确保面板的布局相应更新。

参数
eThe action event / action事件

◆ actionIndex()

int SARibbonPanel::actionIndex ( QAction *  act) const

Gets the index of an action within the panel / 获取一个action在面板内的索引

参数
actThe action to find / 要查找的action
返回
The index of the action, or -1 if not found / action的索引,如果未找到则返回-1

◆ actionToRibbonToolButton()

SARibbonToolButton * SARibbonPanel::actionToRibbonToolButton ( QAction *  action)

Retrieves the SARibbonToolButton associated with an action / 获取与action关联的SARibbonToolButton

参数
actionThe action to query / 要查询的action
返回
The associated tool button, or nullptr if not found / 关联的工具按钮,如果未找到则返回nullptr

◆ actionTriggered

void SARibbonPanel::actionTriggered ( QAction *  action)
signal

等同于QToolBar::actionTriggered

参数
action

◆ addAction() [1/3]

QAction * SARibbonPanel::addAction ( const QString &  text,
const QIcon &  icon,
QToolButton::ToolButtonPopupMode  popMode,
SARibbonPanelItem::RowProportion  rowProportion = SARibbonPanelItem::Large 
)

Creates and adds a new action / 创建并添加一个新的action

This is a convenience function that creates a new QAction, sets its properties, and adds it to the panel. The panel will take ownership of the action.

这是一个便捷函数,用于创建一个新的 QAction,设置其属性,并将其添加到面板。 面板将拥有此action的所有权。

参数
textThe action's text / action的文字
iconThe action's icon / action的图标
popModeThe button's popup mode / 按钮的弹出模式
rpThe action's row proportion / action的行占比
返回
The newly created action / 新创建的action

◆ addAction() [2/3]

void SARibbonPanel::addAction ( QAction *  act,
QToolButton::ToolButtonPopupMode  popMode,
SARibbonPanelItem::RowProportion  rowProportion = SARibbonPanelItem::Large 
)

Adds an action with a specified popup mode / 添加一个具有指定弹出模式的action

参数
actThe action to add / 要添加的action
popModeThe popup mode for the button / 按钮的弹出模式
rpThe row proportion for this action / 此action的行占比

◆ addAction() [3/3]

void SARibbonPanel::addAction ( QAction *  action,
SARibbonPanelItem::RowProportion  rowProportion 
)

Adds an action to the panel / 向面板添加一个action

This is the primary method for populating the panel. The button created for this action will use the row proportion and popup mode previously set via the static property functions.

这是填充面板的主要方法。为此action创建的按钮将使用之前通过静态属性函数设置的行占比和弹出模式。

参数
actionThe action to add / 要添加的action
rpThe row proportion for this action / 此action的行占比
参见
addLargeAction, addMediumAction, addSmallAction

◆ addGallery()

SARibbonGallery * SARibbonPanel::addGallery ( bool  expanding = true)

Adds a gallery widget to the panel / 向面板添加一个画廊窗口部件

A gallery is a specialized widget for displaying a collection of items. If expanding is true, the panel's horizontal size policy will be set to Expanding.

画廊是一个用于显示项目集合的专用窗口部件。如果 expanding 为true, 面板的水平尺寸策略将被设置为 Expanding

参数
expandingIf true, sets the panel's size policy to Expanding / 如果为true,将面板的尺寸策略设置为Expanding
返回
The created SARibbonGallery / 创建的SARibbonGallery

◆ addLargeAction() [1/2]

void SARibbonPanel::addLargeAction ( QAction *  action)

Adds a large action (occupies full height) / 添加一个大action(占据整个高度)

参数
actionThe action to add / 要添加的action

◆ addLargeAction() [2/2]

void SARibbonPanel::addLargeAction ( QAction *  action,
QToolButton::ToolButtonPopupMode  popMode 
)

Adds a large action with a specified popup mode / 添加一个具有指定弹出模式的大action

参数
actionThe action to add / 要添加的action
popModeThe popup mode for the button / 按钮的弹出模式

◆ addLargeMenu()

void SARibbonPanel::addLargeMenu ( QMenu *  menu,
QToolButton::ToolButtonPopupMode  popMode = QToolButton::InstantPopup 
)

Adds a menu as a large button / 以大按钮形式添加一个菜单

参数
menuThe menu to add / 要添加的菜单
popModeThe popup mode / 弹出模式

◆ addLargeWidget()

QAction * SARibbonPanel::addLargeWidget ( QWidget *  w)

Adds a widget as a large button / 以大按钮形式添加一个窗口部件

参数
wThe widget to add / 要添加的窗口部件
返回
The created QWidgetAction / 创建的QWidgetAction

◆ addMediumAction() [1/2]

void SARibbonPanel::addMediumAction ( QAction *  action)

Adds a medium action / 添加一个中等action

In ThreeRowMode, a medium action occupies two rows. In TwoRowMode, it is equivalent to a small action.

在三行模式下,中等action占据两行。在两行模式下,它等同于一个小action。

参数
actionThe action to add / 要添加的action

◆ addMediumAction() [2/2]

void SARibbonPanel::addMediumAction ( QAction *  action,
QToolButton::ToolButtonPopupMode  popMode 
)

Adds a medium action with a specified popup mode / 添加一个具有指定弹出模式的中等action

参数
actionThe action to add / 要添加的action
popModeThe popup mode for the button / 按钮的弹出模式

◆ addMediumMenu()

void SARibbonPanel::addMediumMenu ( QMenu *  menu,
QToolButton::ToolButtonPopupMode  popMode = QToolButton::InstantPopup 
)

Adds a menu as a medium button / 以中按钮形式添加一个菜单

参数
menuThe menu to add / 要添加的菜单
popModeThe popup mode / 弹出模式

◆ addMediumWidget()

QAction * SARibbonPanel::addMediumWidget ( QWidget *  w)

Adds a widget as a medium button / 以中等按钮形式添加一个窗口部件

参数
wThe widget to add / 要添加的窗口部件
返回
The created QWidgetAction / 创建的QWidgetAction

◆ addMenu()

void SARibbonPanel::addMenu ( QMenu *  menu,
SARibbonPanelItem::RowProportion  rowProportion,
QToolButton::ToolButtonPopupMode  popMode = QToolButton::InstantPopup 
)

Adds a menu to the panel / 向面板添加一个菜单

参数
menuThe menu to add / 要添加的菜单
rpThe row proportion for the menu button / 菜单按钮的行占比
popModeThe popup mode, defaults to InstantPopup / 弹出模式,默认为InstantPopup
注解
本函数会修改 menu->menuAction() 的部分属性(icon/text/objectName),如需保留自定义值,请提前设置。

◆ addSeparator()

QAction * SARibbonPanel::addSeparator ( )

Adds a separator / 添加一个分隔符

返回
The created separator action / 创建的分隔符action

◆ addSmallAction() [1/2]

void SARibbonPanel::addSmallAction ( QAction *  action)

Adds a small action / 添加一个小action

参数
actionThe action to add / 要添加的action

◆ addSmallAction() [2/2]

void SARibbonPanel::addSmallAction ( QAction *  action,
QToolButton::ToolButtonPopupMode  popMode 
)

Adds a small action with a specified popup mode / 添加一个具有指定弹出模式的小action

参数
actionThe action to add / 要添加的action
popModeThe popup mode for the button / 按钮的弹出模式

◆ addSmallMenu()

void SARibbonPanel::addSmallMenu ( QMenu *  menu,
QToolButton::ToolButtonPopupMode  popMode = QToolButton::InstantPopup 
)

Adds a menu as a small button / 以小按钮形式添加一个菜单

参数
menuThe menu to add / 要添加的菜单
popModeThe popup mode / 弹出模式

◆ addSmallWidget()

QAction * SARibbonPanel::addSmallWidget ( QWidget *  w)

Adds a widget as a small button / 以小按钮形式添加一个窗口部件

参数
wThe widget to add / 要添加的窗口部件
返回
The created QWidgetAction / 创建的QWidgetAction

◆ addWidget()

QAction * SARibbonPanel::addWidget ( QWidget *  w,
SARibbonPanelItem::RowProportion  rowProportion 
)

Adds a custom widget to the panel / 向面板添加一个自定义窗口部件

The panel will create a QWidgetAction to manage the widget. The panel does not take ownership of the widget; its lifetime is managed by its parent or the caller.

面板将创建一个 QWidgetAction 来管理此窗口部件。面板不拥有此窗口部件的所有权; 其生命周期由其父对象或调用者管理。

参数
wThe widget to add / 要添加的窗口部件
rpThe row proportion for the widget / 窗口部件的行占比
返回
The created QWidgetAction / 创建的QWidgetAction

◆ buttonMaximumAspectRatio()

qreal SARibbonPanel::buttonMaximumAspectRatio ( ) const

按钮最大宽高比,这个系数决定按钮的最大宽度

返回
按钮最大宽高比
参见
setButtonMaximumAspectRatio

◆ category()

SARibbonCategory * SARibbonPanel::category ( ) const

Gets the parent SARibbonCategory / 获取父SARibbonCategory

返回
The parent category, or nullptr if not found / 父category,如果未找到则返回nullptr

◆ changeEvent()

void SARibbonPanel::changeEvent ( QEvent *  e)
protectedvirtual

Handles change events (e.g., font change) / 处理更改事件(例如,字体更改)

This function is called when properties like the font change. It propagates the change to child widgets and invalidates the layout.

当字体等属性更改时会调用此函数。它将更改传播到子窗口部件并使布局失效。

参数
eThe change event / 更改事件

◆ getActionRowProportionProperty()

SARibbonPanelItem::RowProportion SARibbonPanel::getActionRowProportionProperty ( QAction *  action)
static

Gets the row proportion property from an action / 从一个action获取行占比属性

参数
actionThe action to query / 要查询的action
返回
The row proportion, defaults to Large if not set / 行占比,如果未设置则默认为Large
参见
setActionRowProportionProperty

◆ getActionToolButtonPopupModeProperty()

QToolButton::ToolButtonPopupMode SARibbonPanel::getActionToolButtonPopupModeProperty ( QAction *  action)
static

Gets the ToolButtonPopupMode property from an action / 从一个action获取ToolButtonPopupMode属性

参数
actionThe action to query / 要查询的action
返回
The popup mode, defaults to InstantPopup if not set / 弹出模式,如果未设置则默认为InstantPopup
参见
setActionToolButtonPopupModeProperty

◆ getActionToolButtonStyleProperty()

Qt::ToolButtonStyle SARibbonPanel::getActionToolButtonStyleProperty ( QAction *  action)
static

Gets the ToolButtonStyle property from an action / 从一个action获取ToolButtonStyle属性

参数
actionThe action to query / 要查询的action
返回
The button style, defaults to ToolButtonIconOnly if not set / 按钮样式,如果未设置则默认为ToolButtonIconOnly
参见
setActionToolButtonStyleProperty

◆ isCanCustomize()

bool SARibbonPanel::isCanCustomize ( ) const

Checks if customization is allowed / 检查是否允许自定义

返回
true if customization is allowed; otherwise false / 如果允许自定义则返回true;否则返回false
参见
setCanCustomize

◆ isEnableShowTitle()

bool SARibbonPanel::isEnableShowTitle ( ) const

Checks if the panel's title is visible / 检查面板标题是否可见

返回
true if the title is visible; otherwise false / 如果标题可见则返回true;否则返回false

◆ isEnableWordWrap()

bool SARibbonPanel::isEnableWordWrap ( ) const

判断panel的文字是否允许换行

返回

◆ isExpanding()

bool SARibbonPanel::isExpanding ( ) const

Checks if the panel is in expanding mode / 检查面板是否处于扩展模式

返回
true if the horizontal size policy is Expanding; otherwise false / 如果水平尺寸策略为Expanding则返回true;否则返回false
参见
setExpanding

◆ isHaveOptionAction()

bool SARibbonPanel::isHaveOptionAction ( ) const

Checks if an option action is set / 检查是否设置了选项action

返回
true if an option action exists; otherwise false / 如果存在选项action则返回true;否则返回false
参见
setOptionAction

◆ iterateButton()

bool SARibbonPanel::iterateButton ( SARibbonPanel::FpRibbonToolButtonIterate  fp) const

Iterates over all SARibbonToolButton children / 遍历所有SARibbonToolButton子对象

Executes the provided function pointer for each SARibbonToolButton. If the function returns false, iteration stops immediately.

对每个 SARibbonToolButton 执行提供的函数指针。如果函数返回 false, 迭代将立即停止。

Example:

myPanel->iterateButton([](SARibbonToolButton* btn) -> bool {
btn->setToolTip("Visited");
return true; // Continue to next button/继续下一个按钮
});
Ribbon interface adapted tool button / Ribbon界面适用的toolButton
Definition SARibbonToolButton.h:20
参数
fpA function pointer that takes a SARibbonToolButton* and returns a bool / 一个接受SARibbonToolButton*并返回bool的函数指针
返回
true if all buttons were iterated; false if iteration was stopped early / 如果遍历了所有按钮则返回true;如果提前停止则返回false

◆ largeButtonHeight()

int SARibbonPanel::largeButtonHeight ( ) const

Gets the height of the large buttons in this panel / 获取此面板中大按钮的高度

返回
The height of large buttons / 大按钮的高度

◆ lastAddActionButton()

SARibbonToolButton * SARibbonPanel::lastAddActionButton ( )

获取最近添加的按钮

返回
刚才添加的按钮的指针

◆ moveAction()

void SARibbonPanel::moveAction ( int  from,
int  to 
)

Moves an action to a new position / 将一个action移动到新位置

参数
fromThe current index of the action / action的当前索引
toThe new index for the action / action的新索引

◆ panelHeightHint()

int SARibbonPanel::panelHeightHint ( const QFontMetrics &  fm,
PanelLayoutMode  layMode,
int  panelTitleHeight 
)
static

Gets the panel's recommended height / 获取面板的推荐高度

This is a static helper function used internally for layout calculations.

这是一个用于内部布局计算的静态辅助函数。

参数
fmThe font metrics to use for calculation / 用于计算的字体度量
layModeThe layout mode / 布局模式
panelTitleHeightThe height of the panel's title / 面板标题的高度
返回
The recommended height / 推荐的高度

◆ panelLayout()

SARibbonPanelLayout * SARibbonPanel::panelLayout ( ) const

Gets the panel's layout object / 获取面板的布局对象

返回
A pointer to the SARibbonPanelLayout / 指向SARibbonPanelLayout的指针

◆ panelLayoutMode()

SARibbonPanel::PanelLayoutMode SARibbonPanel::panelLayoutMode ( ) const

Gets the current layout mode / 获取当前的布局模式

返回
The current layout mode / 当前的布局模式
参见
setPanelLayoutMode

◆ panelName()

QString SARibbonPanel::panelName ( ) const

Gets the panel's name / 获取面板的名称

返回
The panel's name / 面板的名称
参见
setPanelName

◆ panelNameChanged

void SARibbonPanel::panelNameChanged ( const QString &  n)
signal

Emitted when the panel's name changes / 当面板名称改变时发出

参数
nameThe new name / 新的名称

◆ ribbonBar()

SARibbonBar * SARibbonPanel::ribbonBar ( ) const

Gets the top-level SARibbonBar / 获取顶层的SARibbonBar

返回
The ribbon bar, or nullptr if not found / Ribbon栏,如果未找到则返回nullptr

◆ ribbonPanelItem()

const QList< SARibbonPanelItem * > & SARibbonPanel::ribbonPanelItem ( ) const

获取布局item

返回

◆ ribbonToolButtons()

QList< SARibbonToolButton * > SARibbonPanel::ribbonToolButtons ( ) const

Returns a list of all SARibbonToolButton children / 返回所有SARibbonToolButton子对象的列表

返回
A list of pointers to SARibbonToolButton / SARibbonToolButton指针的列表

◆ setActionRowProportionProperty()

void SARibbonPanel::setActionRowProportionProperty ( QAction *  action,
SARibbonPanelItem::RowProportion  rp 
)
static

Sets the row proportion property for an action / 为一个action设置行占比属性

This property determines how much vertical space the corresponding button will occupy within the panel. It should be set before adding the action to the panel.

此属性决定了对应按钮在面板内占据的垂直空间比例。 应在将action添加到面板之前设置。

参数
actionThe action to modify / 要修改的action
rpThe row proportion (Large, Medium, Small) / 行占比(大、中、小)
参见
addAction, getActionRowProportionProperty

◆ setActionToolButtonPopupModeProperty()

void SARibbonPanel::setActionToolButtonPopupModeProperty ( QAction *  action,
QToolButton::ToolButtonPopupMode  popMode 
)
static

Sets the ToolButtonPopupMode property for an action / 为一个action设置ToolButtonPopupMode属性

参数
actionThe action to modify / 要修改的action
popModeThe popup mode (e.g., InstantPopup, MenuButtonPopup) / 弹出模式(例如,InstantPopup, MenuButtonPopup)
参见
getActionToolButtonPopupModeProperty

◆ setActionToolButtonStyleProperty()

void SARibbonPanel::setActionToolButtonStyleProperty ( QAction *  action,
Qt::ToolButtonStyle  buttonStyle 
)
static

Sets the ToolButtonStyle property for an action / 为一个action设置ToolButtonStyle属性

参数
actionThe action to modify / 要修改的action
buttonStyleThe button style (e.g., ToolButtonIconOnly, ToolButtonTextBesideIcon) / 按钮样式(例如,ToolButtonIconOnly, ToolButtonTextBesideIcon)
参见
getActionToolButtonStyleProperty

◆ setButtonMaximumAspectRatio()

void SARibbonPanel::setButtonMaximumAspectRatio ( qreal  fac = 1.4)
protected

设置按钮最大宽高比,这个系数决定按钮的最大宽度

按钮的最大宽度为按钮高度*此系数,例如按钮高度为h,那么按钮最大宽度maxw=h*buttonMaximumAspectRatio 如果在此宽度下文字还无法完全显示,那么按钮将不会继续横向扩展,将使用...替代未完全显示的文字

参见
buttonMaximumAspectRatio
注解
用户不应该调用SARibbonPanel::setButtonMaximumAspectRatio 来设置, 而是调用SARibbonBar::setButtonMaximumAspectRatio 设置宽高比

◆ setCanCustomize()

void SARibbonPanel::setCanCustomize ( bool  b)

Sets whether customization is allowed / 设置是否允许自定义

参数
bIf true, customization is allowed / 如果为true,则允许自定义
参见
isCanCustomize

◆ setEnableShowTitle()

void SARibbonPanel::setEnableShowTitle ( bool  on)
protected

Sets whether the panel's title is visible / 设置面板标题是否可见

This function is typically called by SARibbonBar and is protected to prevent direct user manipulation.

此函数通常由 SARibbonBar 调用,为防止用户直接操作而设为protected。

参数
onIf true, the title is visible / 如果为true,则标题可见
参见
SARibbonBar::setEnableShowPanelTitle

◆ setEnableWordWrap()

void SARibbonPanel::setEnableWordWrap ( bool  on)
protected

设置panel的按钮文字允许换行

参数
on

◆ setExpanding()

void SARibbonPanel::setExpanding ( bool  isExpanding = true)

Sets the panel to expanding mode / 将面板设置为扩展模式

In expanding mode, the panel will try to occupy all available horizontal space in its parent layout.

在扩展模式下,面板将尝试占据其父布局中所有可用的水平空间。

参数
isExpandingIf true, sets the horizontal size policy to Expanding / 如果为true,将水平尺寸策略设置为Expanding
参见
isExpanding

◆ setOptionAction()

void SARibbonPanel::setOptionAction ( QAction *  action)

Sets the option action for the panel / 为面板设置选项action

The option action is typically displayed as a small button in the panel's title area. Pass nullptr to remove the current option action.

选项action通常显示在面板标题区域的一个小按钮中。 传入 nullptr 以移除当前的选项action。

参数
actionThe option action, or nullptr to remove / 选项action,或传入nullptr以移除
参见
isHaveOptionAction

◆ setPanelLayoutMode()

void SARibbonPanel::setPanelLayoutMode ( SARibbonPanel::PanelLayoutMode  mode)

Sets the panel's layout mode / 设置面板的布局模式

参数
modeThe new layout mode (ThreeRowMode or TwoRowMode) / 新的布局模式(三行模式或两行模式)
参见
panelLayoutMode

◆ setPanelName()

void SARibbonPanel::setPanelName ( const QString &  title)

Sets the panel's name / 设置面板的名称

Setting the name will also emit the panelNameChanged signal.

设置名称还会发出 panelNameChanged 信号。

参数
titleThe new name for the panel / 面板的新名称
参见
panelName

◆ setSpacing()

void SARibbonPanel::setSpacing ( int  n)
protected

Sets the spacing between elements in the panel / 设置面板内元素之间的间距

This function is typically called by SARibbonBar and is protected to prevent direct user manipulation.

此函数通常由 SARibbonBar 调用,为防止用户直接操作而设为protected。

参数
nThe new spacing value / 新的间距值
参见
SARibbonBar::setPanelSpacing

◆ setTitleHeight()

void SARibbonPanel::setTitleHeight ( int  h)
protected

Sets the height of the panel's title / 设置面板标题的高度

This function is typically called by SARibbonBar and is protected to prevent direct user manipulation.

此函数通常由 SARibbonBar 调用,为防止用户直接操作而设为protected。

参数
hThe new title height / 新的标题高度
参见
SARibbonBar::setPanelTitleHeight

◆ setToolButtonIconSize()

void SARibbonPanel::setToolButtonIconSize ( const QSize &  s)

Sets the icon size for all tool buttons in the panel / 设置面板内所有工具按钮的图标尺寸

This sets the default icon size for newly created buttons and updates the icon size for existing buttons.

此函数设置新创建按钮的默认图标尺寸,并更新现有按钮的图标尺寸。

参数
sThe new icon size / 新的图标尺寸
参见
toolButtonIconSize

◆ spacing()

int SARibbonPanel::spacing ( ) const

Gets the spacing between elements in the panel / 获取面板内元素之间的间距

返回
The current spacing value / 当前的间距值
参见
setSpacing

◆ titleHeight()

int SARibbonPanel::titleHeight ( ) const

Gets the height of the panel's title / 获取面板标题的高度

返回
The current title height / 当前的标题高度

◆ titleLabel()

SARibbonPanelLabel * SARibbonPanel::titleLabel ( ) const

Gets the title label widget / 获取标题标签窗口部件

返回
A pointer to the SARibbonPanelLabel / 指向SARibbonPanelLabel的指针

◆ toolButtonIconSize()

QSize SARibbonPanel::toolButtonIconSize ( ) const

Gets the current default icon size for tool buttons / 获取工具按钮当前的默认图标尺寸

返回
The current icon size / 当前的图标尺寸
参见
setToolButtonIconSize

◆ updateItemGeometry()

void SARibbonPanel::updateItemGeometry ( )

Updates the geometry of all items in the panel / 更新面板内所有项目的几何形状

This function forces a recalculation of the layout and size hints for all buttons and items.

此函数强制重新计算所有按钮和项目的布局及尺寸提示。


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