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

Ribbon控件中的分类选项卡页面(Category) 更多...

#include <SARibbonCategory.h>

类 SARibbonCategory 继承关系图:

class  PrivateData
 SARibbonCategory::PrivateData
 

Public 类型

using FpPanelIterate = std::function< bool(SARibbonPanel *) >
 

信号

void categoryNameChanged (const QString &n)
 Category title changed signal/category标题发生了改变信号
 
void actionTriggered (QAction *action)
 Refer to QToolBar::actionTriggered signal/参考QToolBar::actionTriggered的信号
 

Public 成员函数

 SARibbonCategory (QWidget *p=nullptr)
 
 SARibbonCategory (const QString &name, QWidget *p=nullptr)
 带名称的构造函数
 
QString categoryName () const
 Get the category name/获取Category名称
 
void setCategoryName (const QString &title)
 Set the category name/设置Category名称
 
SARibbonPanel::PanelLayoutMode panelLayoutMode () const
 Get the panel layout mode/获取面板布局模式
 
void setPanelLayoutMode (SARibbonPanel::PanelLayoutMode m)
 Set the panel layout mode/设置面板布局模式
 
SARibbonPaneladdPanel (const QString &title)
 Add a panel (panel)/添加面板(panel)
 
void addPanel (SARibbonPanel *panel)
 Add panel/添加panel
 
Q_INVOKABLE void addPanel (QWidget *panel)
 Qt Designer specific/Qt Designer专用
 
SARibbonPanelinsertPanel (const QString &title, int index)
 Create a new panel and insert it at the index position/新建一个panel,并插入到index位置
 
SARibbonPanelpanelByName (const QString &title) const
 Find panel by name/通过名字查找panel
 
SARibbonPanelpanelByObjectName (const QString &objname) const
 Find panel by ObjectName/通过ObjectName查找panel
 
SARibbonPanelpanelByIndex (int index) const
 Find panel by index, returns nullptr if the index is out of range/通过索引找到panel,如果超过索引范围,会返回nullptr
 
int panelIndex (SARibbonPanel *p) const
 Find the index corresponding to panel/查找panel对应的索引
 
void movePanel (int from, int to)
 Move a Panel from from index to to index/移动一个Panel从from index到to index
 
bool takePanel (SARibbonPanel *panel)
 Detach panel from SARibbonCategory management/把panel脱离SARibbonCategory的管理
 
bool removePanel (SARibbonPanel *panel)
 Remove Panel, Category will directly recycle SARibbonPanel memory/移除Panel,Category会直接回收SARibbonPanel内存
 
bool removePanel (int index)
 Remove panel/移除panel
 
QList< SARibbonPanel * > panelList () const
 Return all panels under Category/返回Category下的所有panel
 
bool isContextCategory () const
 Returns true if it is a ContextCategory/如果是ContextCategory,此函数返回true
 
int panelCount () const
 Return the number of panels/返回panel的个数
 
bool isCanCustomize () const
 Determine if customization is allowed/判断是否可以自定义
 
void setCanCustomize (bool b)
 Set whether customization is allowed/设置是否可以自定义
 
int panelTitleHeight () const
 Height of panel title bar/panel标题栏的高度
 
void setPanelTitleHeight (int h)
 Set the height of panel/设置panel的高度
 
bool isEnableShowPanelTitle () const
 Whether the panel title bar is displayed/是否panel显示标题栏
 
void setEnableShowPanelTitle (bool on)
 Set to display panel title/设置显示panel标题
 
void setCategoryAlignment (SARibbonAlignment al)
 Set the alignment of Category/设置Category的对齐方式
 
SARibbonAlignment categoryAlignment () const
 Category alignment/Category的对齐方式
 
void setPanelSpacing (int n)
 Set the spacing of panel/设置panel的spacing
 
int panelSpacing () const
 panel spacing/panel的spacing
 
void setPanelToolButtonIconSize (const QSize &s)
 Set the icon size of panel buttons, large action is not affected/设置panel按钮的icon尺寸,large action不受此尺寸影响
 
QSize panelToolButtonIconSize () const
 Icon size of panel buttons, large action is not affected/panel按钮的icon尺寸,large action不受此尺寸影响
 
SARibbonBarribbonBar () const
 Get the corresponding ribbonbar, returns null if not managed by ribbonbar/获取对应的ribbonbar,如果没有加入ribbonbar的管理,此值为null
 
void updateItemGeometry ()
 Refresh the category layout, suitable for calling after changing the ribbon mode/刷新category的布局,适用于改变ribbon的模式之后调用
 
void setUseAnimatingScroll (bool useAnimating)
 Set whether to use animation when scrolling/设置滚动时是否使用动画
 
bool isUseAnimatingScroll () const
 Whether to use animation when scrolling/滚动时是否使用动画
 
void setWheelScrollStep (int step)
 Set wheel scroll step (px)/设置滚轮滚动步长(px)
 
int wheelScrollStep () const
 Wheel scroll step/滚轮的滚动步长
 
void setAnimationDuration (int duration)
 Set animation duration/设置动画持续时间
 
int animationDuration () const
 Animation duration/动画持续时间
 
bool isEnableWordWrap () const
 Determine whether the text of panel is allowed to wrap/判断panel的文字是否允许换行
 
qreal buttonMaximumAspectRatio () const
 Button maximum aspect ratio, this coefficient determines the maximum width of the button/按钮最大宽高比,这个系数决定按钮的最大宽度
 
bool iteratePanel (FpPanelIterate fp) const
 This function will iterate through all panels under Category and execute the function pointer/此函数会遍历Category下的所有panel,执行函数指针
 
QSize sizeHint () const Q_DECL_OVERRIDE
 

Protected 成员函数

virtual bool event (QEvent *e) override
 
void wheelEvent (QWheelEvent *event) override
 滚动事件
 
void changeEvent (QEvent *event) override
 
void markIsContextCategory (bool isContextCategory=true)
 Mark this as a context label/标记这个是上下文标签
 
SARibbonCategoryLayoutcategoryLayout () const
 Get SARibbonCategoryLayoutlayout/获取SARibbonCategoryLayoutlayout
 
void setEnableWordWrap (bool on)
 Set whether the text of panel buttons is allowed to wrap/设置panel的按钮文字允许换行
 
void setButtonMaximumAspectRatio (qreal fac=1.4)
 Set button maximum aspect ratio, this coefficient determines the maximum width of the button/设置按钮最大宽高比,这个系数决定按钮的最大宽度
 

属性

bool isCanCustomize
 
QString categoryName
 

友元

class SARibbonBar
 
class SARibbonContextCategory
 

详细描述

Ribbon控件中的分类选项卡页面(Category)

每个Category代表Ribbon中的一个标签页,包含多个面板(Panel)

The SARibbonCategory is a tab page in the Ribbon interface that contains multiple panels (SARibbonPanel). It acts as a container for organizing related actions and controls into logical groups.

SARibbonCategory是Ribbon界面中的一个标签页,包含多个面板 (SARibbonPanel)。 它作为容器,用于将相关的操作和控件按逻辑分组组织起来。


添加面板 / Adding Panels

You can add panels to a category using functions like addPanel, insertPanel, etc. Panels can be added either by specifying a title (which creates a new panel) or by passing an existing panel object.

可以使用 @ref insertPanel 等函数向分类中添加面板。 面板可以通过指定标题(创建新面板)或传递现有面板对象来添加。


上下文分类 / Context Categories

A category can be marked as a context category using markIsContextCategory. Context categories are typically used for specific scenarios or modes, such as formatting options when text is selected.

可以使用 markIsContextCategory 将分类标记为上下文分类。 上下文分类通常用于特定场景或模式,例如选择文本时的格式化选项。


自定义 / Customization

Categories support customization features. You can control whether a category can be customized using setCanCustomize.

分类支持自定义功能。您可以使用 setCanCustomize 控制分类是否可以自定义。


滚动 / Scrolling

When the content of a category exceeds its width, it can be scrolled horizontally using the mouse wheel or scroll buttons. The scrolling behavior can be configured with functions like setUseAnimatingScroll, setWheelScrollStep, and setAnimationDuration.

当分类的内容超过其宽度时,可以通过鼠标滚轮或滚动按钮进行水平滚动。 滚动行为可以通过 @ref setWheelScrollStep 和 setAnimationDuration 等函数进行配置。

构造及析构函数说明

◆ SARibbonCategory()

SARibbonCategory::SARibbonCategory ( const QString &  name,
QWidget *  p = nullptr 
)
explicit

带名称的构造函数

参数
nameCategory名称
p父级控件指针

成员函数说明

◆ actionTriggered

void SARibbonCategory::actionTriggered ( QAction *  action)
signal

Refer to QToolBar::actionTriggered signal/参考QToolBar::actionTriggered的信号

参数
actionTriggered action/被触发的动作

◆ addPanel() [1/3]

SARibbonPanel * SARibbonCategory::addPanel ( const QString &  title)

Add a panel (panel)/添加面板(panel)

注解
The ownership of the panel (panel) is managed by SARibbonCategory, please do not destroy it externally/面板(panel)的所有权由SARibbonCategory来管理,请不要在外部对其进行销毁
参数
titlePanel (panel) title, which will be displayed below the panel (panel) in the three-row mode of office/wps / 面板(panel)的标题,在office/wps的三行模式下会显示在面板(panel)的下方
返回
Returns a pointer to the generated SARibbonPanel / 返回生成的SARibbonPanel 指针
参见
For other operations on SARibbonPanel, refer to SARibbonCategory::takePanel

对SARibbonPanel的其他操作,参考 SARibbonCategory::takePanel

◆ addPanel() [2/3]

void SARibbonCategory::addPanel ( QWidget *  panel)

Qt Designer specific/Qt Designer专用

参数
panel

◆ addPanel() [3/3]

void SARibbonCategory::addPanel ( SARibbonPanel panel)

Add panel/添加panel

参数
panelpanel ownership is managed by SARibbonCategory panel的所有权SARibbonCategory来管理

◆ animationDuration()

int SARibbonCategory::animationDuration ( ) const

Animation duration/动画持续时间

返回
Current animation duration in milliseconds, or -1 if not available/当前以毫秒为单位的动画持续时间,如果不可用则返回-1

◆ buttonMaximumAspectRatio()

qreal SARibbonCategory::buttonMaximumAspectRatio ( ) const

Button maximum aspect ratio, this coefficient determines the maximum width of the button/按钮最大宽高比,这个系数决定按钮的最大宽度

返回
Current button maximum aspect ratio/当前按钮最大宽高比
参见
setButtonMaximumAspectRatio

◆ categoryAlignment()

SARibbonAlignment SARibbonCategory::categoryAlignment ( ) const

Category alignment/Category的对齐方式

返回
Current alignment of the category/分类的当前对齐方式

◆ categoryLayout()

SARibbonCategoryLayout * SARibbonCategory::categoryLayout ( ) const
protected

Get SARibbonCategoryLayoutlayout/获取SARibbonCategoryLayoutlayout

返回
Pointer to the category layout, or nullptr if not available/指向分类布局的指针,如果不可用则返回nullptr

◆ categoryName()

QString SARibbonCategory::categoryName ( ) const

Get the category name/获取Category名称

返回
Current category name (i.e., windowTitle)/当前Category的名称(即windowTitle)

◆ categoryNameChanged

void SARibbonCategory::categoryNameChanged ( const QString &  n)
signal

Category title changed signal/category标题发生了改变信号

参数
nNew category name/新的分类名称

◆ insertPanel()

SARibbonPanel * SARibbonCategory::insertPanel ( const QString &  title,
int  index 
)

Create a new panel and insert it at the index position/新建一个panel,并插入到index位置

参数
titlepanel title/panel的title
indexInsertion position, if index exceeds the number of panels in the category, it will be inserted at the end/插入的位置,如果index超出category里panel的个数,将插入到最后
返回
Returns a pointer to the generated SARibbonPanel

◆ isCanCustomize()

bool SARibbonCategory::isCanCustomize ( ) const

Determine if customization is allowed/判断是否可以自定义

返回
True if customization is allowed, false otherwise/如果允许自定义返回true,否则返回false

◆ isContextCategory()

bool SARibbonCategory::isContextCategory ( ) const

Returns true if it is a ContextCategory/如果是ContextCategory,此函数返回true

返回
True if this is a context category, false otherwise/如果是上下文分类返回true,否则返回false

◆ isEnableShowPanelTitle()

bool SARibbonCategory::isEnableShowPanelTitle ( ) const

Whether the panel title bar is displayed/是否panel显示标题栏

返回
True if panel title bars are displayed, false otherwise/如果显示panel标题栏返回true,否则返回false

◆ isEnableWordWrap()

bool SARibbonCategory::isEnableWordWrap ( ) const

Determine whether the text of panel is allowed to wrap/判断panel的文字是否允许换行

返回
True if text wrapping is enabled, false otherwise/如果启用文字换行返回true,否则返回false

◆ isUseAnimatingScroll()

bool SARibbonCategory::isUseAnimatingScroll ( ) const

Whether to use animation when scrolling/滚动时是否使用动画

返回
True if animation is used, false otherwise/如果使用动画返回true,否则返回false

◆ iteratePanel()

bool SARibbonCategory::iteratePanel ( FpPanelIterate  fp) const

This function will iterate through all panels under Category and execute the function pointer/此函数会遍历Category下的所有panel,执行函数指针

参数
fpFunction pointer returns false to stop iteration/函数指针返回false则停止迭代
返回
Returns false indicating that all categories have not been iterated. The iteration was interrupted by receiving a false return from the callback function/返回false代表没有迭代完所有的category,中途接收到回调函数的false返回而中断迭代

◆ markIsContextCategory()

void SARibbonCategory::markIsContextCategory ( bool  isContextCategory = true)
protected

Mark this as a context label/标记这个是上下文标签

参数
isContextCategoryTrue to mark as context category, false otherwise/为true标记为上下文分类,否则为false

◆ movePanel()

void SARibbonCategory::movePanel ( int  from,
int  to 
)

Move a Panel from from index to to index/移动一个Panel从from index到to index

参数
fromIndex of the panel to move/要移动panel的index
toPosition to move to/要移动到的位置

◆ panelByIndex()

SARibbonPanel * SARibbonCategory::panelByIndex ( int  index) const

Find panel by index, returns nullptr if the index is out of range/通过索引找到panel,如果超过索引范围,会返回nullptr

参数
index
返回
Returns nullptr if the index is out of range/如果超过索引范围,会返回nullptr

◆ panelByName()

SARibbonPanel * SARibbonCategory::panelByName ( const QString &  title) const

Find panel by name/通过名字查找panel

参数
title
返回
If there are duplicate names, only the first one that meets the condition will be returned/如果有重名,只会返回第一个符合条件的

◆ panelByObjectName()

SARibbonPanel * SARibbonCategory::panelByObjectName ( const QString &  objname) const

Find panel by ObjectName/通过ObjectName查找panel

参数
objname
返回

◆ panelCount()

int SARibbonCategory::panelCount ( ) const

Return the number of panels/返回panel的个数

返回
Number of panels in the category/分类中panel的数量

◆ panelIndex()

int SARibbonCategory::panelIndex ( SARibbonPanel p) const

Find the index corresponding to panel/查找panel对应的索引

参数
p
返回
Returns -1 if not found/如果找不到,返回-1

◆ panelLayoutMode()

SARibbonPanel::PanelLayoutMode SARibbonCategory::panelLayoutMode ( ) const

Get the panel layout mode/获取面板布局模式

返回
Current layout mode for all panels/当前所有面板的布局模式

◆ panelList()

QList< SARibbonPanel * > SARibbonCategory::panelList ( ) const

Return all panels under Category/返回Category下的所有panel

返回
List of all panels in the category/分类中所有panel的列表

◆ panelSpacing()

int SARibbonCategory::panelSpacing ( ) const

panel spacing/panel的spacing

返回
Current spacing between panels/当前panel之间的间距

◆ panelTitleHeight()

int SARibbonCategory::panelTitleHeight ( ) const

Height of panel title bar/panel标题栏的高度

返回
Current height of panel title bars/当前panel标题栏的高度

◆ panelToolButtonIconSize()

QSize SARibbonCategory::panelToolButtonIconSize ( ) const

Icon size of panel buttons, large action is not affected/panel按钮的icon尺寸,large action不受此尺寸影响

返回
Current icon size for panel buttons/当前panel按钮的图标大小

◆ removePanel() [1/2]

bool SARibbonCategory::removePanel ( int  index)

Remove panel/移除panel

参数
indexIndex of panel, returns false if it exceeds the limit/panel的索引,如果超出会返回false
返回
Returns true on success/成功返回true

◆ removePanel() [2/2]

bool SARibbonCategory::removePanel ( SARibbonPanel panel)

Remove Panel, Category will directly recycle SARibbonPanel memory/移除Panel,Category会直接回收SARibbonPanel内存

参数
panelPanel to remove/需要移除的panel
注解
After removal, panel becomes a wild pointer. It is generally recommended to set the panel pointer to nullptr after the operation

This operation is equivalent to:

此操作等同于:

...
panel->hide();
panel->deleteLater();
bool takePanel(SARibbonPanel *panel)
Detach panel from SARibbonCategory management/把panel脱离SARibbonCategory的管理
Definition SARibbonCategory.cpp:454
panel页窗口,panel是ribbon的面板用于承放控件 / Ribbon panel container, used to hold controls
Definition SARibbonPanel.h:93
SARibbonCategory * category() const
Gets the parent SARibbonCategory / 获取父SARibbonCategory
Definition SARibbonPanel.cpp:935

移除后panel为野指针,一般操作完建议把panel指针设置为nullptr

◆ ribbonBar()

SARibbonBar * SARibbonCategory::ribbonBar ( ) const

Get the corresponding ribbonbar, returns null if not managed by ribbonbar/获取对应的ribbonbar,如果没有加入ribbonbar的管理,此值为null

返回
Returns null if not managed by ribbonbar/如果没有加入ribbonbar的管理,此值为null

◆ setAnimationDuration()

void SARibbonCategory::setAnimationDuration ( int  duration)

Set animation duration/设置动画持续时间

参数
durationAnimation duration in milliseconds/以毫秒为单位的动画持续时间

◆ setButtonMaximumAspectRatio()

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

Set button maximum aspect ratio, this coefficient determines the maximum width of the button/设置按钮最大宽高比,这个系数决定按钮的最大宽度

The maximum width of the button is button height * this coefficient. For example, if the button height is h, then the maximum button width maxw = h * buttonMaximumAspectRatio If the text cannot be fully displayed at this width, the button will not continue to expand horizontally, and ... will be used instead of the incompletely displayed text

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

参见
buttonMaximumAspectRatio
注解
Users should not call SARibbonCategory::setButtonMaximumAspectRatio to set, but call SARibbonBar::setButtonMaximumAspectRatio to set the aspect ratio

用户不应该调用SARibbonCategory::setButtonMaximumAspectRatio 来设置, 而是调用SARibbonBar::setButtonMaximumAspectRatio 设置宽高比

参数
facNew maximum aspect ratio/新的最大宽高比

◆ setCanCustomize()

void SARibbonCategory::setCanCustomize ( bool  b)

Set whether customization is allowed/设置是否可以自定义

参数
bTrue to allow customization, false to disallow/为true允许自定义,为false禁止自定义

◆ setCategoryAlignment()

void SARibbonCategory::setCategoryAlignment ( SARibbonAlignment  al)

Set the alignment of Category/设置Category的对齐方式

参数
alAlignment for the category/分类的对齐方式

◆ setCategoryName()

void SARibbonCategory::setCategoryName ( const QString &  title)

Set the category name/设置Category名称

参数
titleNew name (equivalent to setWindowTitle)/新名称(等价于setWindowTitle)

◆ setEnableShowPanelTitle()

void SARibbonCategory::setEnableShowPanelTitle ( bool  on)

Set to display panel title/设置显示panel标题

参数
onTrue to display panel title bars, false to hide them/为true显示panel标题栏,为false隐藏它们

◆ setEnableWordWrap()

void SARibbonCategory::setEnableWordWrap ( bool  on)
protected

Set whether the text of panel buttons is allowed to wrap/设置panel的按钮文字允许换行

参数
onTrue to enable text wrapping, false to disable/为true启用文字换行,为false禁用

◆ setPanelLayoutMode()

void SARibbonCategory::setPanelLayoutMode ( SARibbonPanel::PanelLayoutMode  m)

Set the panel layout mode/设置面板布局模式

SARibbonBar 调用SARibbonBar::setRibbonStyle 函数时,会对所有的SARibbonCategory调用此函数 把新的SARibbonPanel::PanelLayoutMode设置进去

参数
m

◆ setPanelSpacing()

void SARibbonCategory::setPanelSpacing ( int  n)

Set the spacing of panel/设置panel的spacing

参数
nSpacing between panels/panel之间的间距

◆ setPanelTitleHeight()

void SARibbonCategory::setPanelTitleHeight ( int  h)

Set the height of panel/设置panel的高度

参数
hNew height for panel title bars/panel标题栏的新高度

◆ setPanelToolButtonIconSize()

void SARibbonCategory::setPanelToolButtonIconSize ( const QSize &  s)

Set the icon size of panel buttons, large action is not affected/设置panel按钮的icon尺寸,large action不受此尺寸影响

参数
sNew icon size for panel buttons/panel按钮的新图标大小

◆ setUseAnimatingScroll()

void SARibbonCategory::setUseAnimatingScroll ( bool  useAnimating)

Set whether to use animation when scrolling/设置滚动时是否使用动画

参数
useAnimatingTrue to use animation, false to scroll directly/为true使用动画,为false直接滚动

◆ setWheelScrollStep()

void SARibbonCategory::setWheelScrollStep ( int  step)

Set wheel scroll step (px)/设置滚轮滚动步长(px)

参数
stepScroll step in pixels/以像素为单位的滚动步长

◆ takePanel()

bool SARibbonCategory::takePanel ( SARibbonPanel panel)

Detach panel from SARibbonCategory management/把panel脱离SARibbonCategory的管理

参数
panelPanel to extract/需要提取的panel
返回
Returns true on success, otherwise false/成功返回true,否则返回false

◆ wheelEvent()

void SARibbonCategory::wheelEvent ( QWheelEvent *  event)
overrideprotected

滚动事件

在内容超出category的宽度情况下,滚轮可滚动panel

参数
event

◆ wheelScrollStep()

int SARibbonCategory::wheelScrollStep ( ) const

Wheel scroll step/滚轮的滚动步长

返回
Current scroll step in pixels/当前以像素为单位的滚动步长

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