![]() |
SARibbon 2.5.1
SARibbon wiki
|
Ribbon控件中的分类选项卡页面(Category) 更多...
#include <SARibbonCategory.h>
类 | |
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/设置面板布局模式 | |
SARibbonPanel * | addPanel (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专用 | |
SARibbonPanel * | insertPanel (const QString &title, int index) |
Create a new panel and insert it at the index position/新建一个panel,并插入到index位置 | |
SARibbonPanel * | panelByName (const QString &title) const |
Find panel by name/通过名字查找panel | |
SARibbonPanel * | panelByObjectName (const QString &objname) const |
Find panel by ObjectName/通过ObjectName查找panel | |
SARibbonPanel * | panelByIndex (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不受此尺寸影响 | |
SARibbonBar * | ribbonBar () 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/标记这个是上下文标签 | |
SARibbonCategoryLayout * | categoryLayout () 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)。 它作为容器,用于将相关的操作和控件按逻辑分组组织起来。
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 等函数向分类中添加面板。 面板可以通过指定标题(创建新面板)或传递现有面板对象来添加。
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 将分类标记为上下文分类。 上下文分类通常用于特定场景或模式,例如选择文本时的格式化选项。
Categories support customization features. You can control whether a category can be customized using setCanCustomize.
分类支持自定义功能。您可以使用 setCanCustomize 控制分类是否可以自定义。
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 等函数进行配置。
|
explicit |
带名称的构造函数
name | Category名称 |
p | 父级控件指针 |
|
signal |
Refer to QToolBar::actionTriggered signal/参考QToolBar::actionTriggered的信号
action | Triggered action/被触发的动作 |
SARibbonPanel * SARibbonCategory::addPanel | ( | const QString & | title | ) |
Add a panel (panel)/添加面板(panel)
title | Panel (panel) title, which will be displayed below the panel (panel) in the three-row mode of office/wps / 面板(panel)的标题,在office/wps的三行模式下会显示在面板(panel)的下方 |
对SARibbonPanel的其他操作,参考 SARibbonCategory::takePanel
void SARibbonCategory::addPanel | ( | QWidget * | panel | ) |
Qt Designer specific/Qt Designer专用
panel |
void SARibbonCategory::addPanel | ( | SARibbonPanel * | panel | ) |
Add panel/添加panel
panel | panel ownership is managed by SARibbonCategory panel的所有权SARibbonCategory来管理 |
int SARibbonCategory::animationDuration | ( | ) | const |
Animation duration/动画持续时间
qreal SARibbonCategory::buttonMaximumAspectRatio | ( | ) | const |
Button maximum aspect ratio, this coefficient determines the maximum width of the button/按钮最大宽高比,这个系数决定按钮的最大宽度
SARibbonAlignment SARibbonCategory::categoryAlignment | ( | ) | const |
Category alignment/Category的对齐方式
|
protected |
Get SARibbonCategoryLayoutlayout/获取SARibbonCategoryLayoutlayout
QString SARibbonCategory::categoryName | ( | ) | const |
Get the category name/获取Category名称
|
signal |
Category title changed signal/category标题发生了改变信号
n | New category name/新的分类名称 |
SARibbonPanel * SARibbonCategory::insertPanel | ( | const QString & | title, |
int | index | ||
) |
Create a new panel and insert it at the index position/新建一个panel,并插入到index位置
title | panel title/panel的title |
index | Insertion position, if index exceeds the number of panels in the category, it will be inserted at the end/插入的位置,如果index超出category里panel的个数,将插入到最后 |
bool SARibbonCategory::isCanCustomize | ( | ) | const |
Determine if customization is allowed/判断是否可以自定义
bool SARibbonCategory::isContextCategory | ( | ) | const |
Returns true if it is a ContextCategory/如果是ContextCategory,此函数返回true
bool SARibbonCategory::isEnableShowPanelTitle | ( | ) | const |
Whether the panel title bar is displayed/是否panel显示标题栏
bool SARibbonCategory::isEnableWordWrap | ( | ) | const |
Determine whether the text of panel is allowed to wrap/判断panel的文字是否允许换行
bool SARibbonCategory::isUseAnimatingScroll | ( | ) | const |
Whether to use animation when scrolling/滚动时是否使用动画
bool SARibbonCategory::iteratePanel | ( | FpPanelIterate | fp | ) | const |
This function will iterate through all panels under Category and execute the function pointer/此函数会遍历Category下的所有panel,执行函数指针
fp | Function pointer returns false to stop iteration/函数指针返回false则停止迭代 |
|
protected |
Mark this as a context label/标记这个是上下文标签
isContextCategory | True to mark as context category, false otherwise/为true标记为上下文分类,否则为false |
void SARibbonCategory::movePanel | ( | int | from, |
int | to | ||
) |
Move a Panel from from index to to index/移动一个Panel从from index到to index
from | Index of the panel to move/要移动panel的index |
to | Position to move to/要移动到的位置 |
SARibbonPanel * SARibbonCategory::panelByIndex | ( | int | index | ) | const |
Find panel by index, returns nullptr if the index is out of range/通过索引找到panel,如果超过索引范围,会返回nullptr
index |
SARibbonPanel * SARibbonCategory::panelByName | ( | const QString & | title | ) | const |
Find panel by name/通过名字查找panel
title |
SARibbonPanel * SARibbonCategory::panelByObjectName | ( | const QString & | objname | ) | const |
Find panel by ObjectName/通过ObjectName查找panel
objname |
int SARibbonCategory::panelCount | ( | ) | const |
Return the number of panels/返回panel的个数
int SARibbonCategory::panelIndex | ( | SARibbonPanel * | p | ) | const |
Find the index corresponding to panel/查找panel对应的索引
p |
SARibbonPanel::PanelLayoutMode SARibbonCategory::panelLayoutMode | ( | ) | const |
Get the panel layout mode/获取面板布局模式
QList< SARibbonPanel * > SARibbonCategory::panelList | ( | ) | const |
Return all panels under Category/返回Category下的所有panel
int SARibbonCategory::panelSpacing | ( | ) | const |
panel spacing/panel的spacing
int SARibbonCategory::panelTitleHeight | ( | ) | const |
Height of panel title bar/panel标题栏的高度
QSize SARibbonCategory::panelToolButtonIconSize | ( | ) | const |
Icon size of panel buttons, large action is not affected/panel按钮的icon尺寸,large action不受此尺寸影响
bool SARibbonCategory::removePanel | ( | int | index | ) |
Remove panel/移除panel
index | Index of panel, returns false if it exceeds the limit/panel的索引,如果超出会返回false |
bool SARibbonCategory::removePanel | ( | SARibbonPanel * | panel | ) |
Remove Panel, Category will directly recycle SARibbonPanel memory/移除Panel,Category会直接回收SARibbonPanel内存
panel | Panel to remove/需要移除的panel |
This operation is equivalent to:
此操作等同于:
移除后panel为野指针,一般操作完建议把panel指针设置为nullptr
SARibbonBar * SARibbonCategory::ribbonBar | ( | ) | const |
Get the corresponding ribbonbar, returns null if not managed by ribbonbar/获取对应的ribbonbar,如果没有加入ribbonbar的管理,此值为null
void SARibbonCategory::setAnimationDuration | ( | int | duration | ) |
Set animation duration/设置动画持续时间
duration | Animation duration in milliseconds/以毫秒为单位的动画持续时间 |
|
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 如果在此宽度下文字还无法完全显示,那么按钮将不会继续横向扩展,将使用...替代未完全显示的文字
用户不应该调用SARibbonCategory::setButtonMaximumAspectRatio 来设置, 而是调用SARibbonBar::setButtonMaximumAspectRatio 设置宽高比
fac | New maximum aspect ratio/新的最大宽高比 |
void SARibbonCategory::setCanCustomize | ( | bool | b | ) |
Set whether customization is allowed/设置是否可以自定义
b | True to allow customization, false to disallow/为true允许自定义,为false禁止自定义 |
void SARibbonCategory::setCategoryAlignment | ( | SARibbonAlignment | al | ) |
Set the alignment of Category/设置Category的对齐方式
al | Alignment for the category/分类的对齐方式 |
void SARibbonCategory::setCategoryName | ( | const QString & | title | ) |
Set the category name/设置Category名称
title | New name (equivalent to setWindowTitle)/新名称(等价于setWindowTitle) |
void SARibbonCategory::setEnableShowPanelTitle | ( | bool | on | ) |
Set to display panel title/设置显示panel标题
on | True to display panel title bars, false to hide them/为true显示panel标题栏,为false隐藏它们 |
|
protected |
Set whether the text of panel buttons is allowed to wrap/设置panel的按钮文字允许换行
on | True to enable text wrapping, false to disable/为true启用文字换行,为false禁用 |
void SARibbonCategory::setPanelLayoutMode | ( | SARibbonPanel::PanelLayoutMode | m | ) |
Set the panel layout mode/设置面板布局模式
在SARibbonBar 调用SARibbonBar::setRibbonStyle 函数时,会对所有的SARibbonCategory调用此函数 把新的SARibbonPanel::PanelLayoutMode设置进去
m |
void SARibbonCategory::setPanelSpacing | ( | int | n | ) |
Set the spacing of panel/设置panel的spacing
n | Spacing between panels/panel之间的间距 |
void SARibbonCategory::setPanelTitleHeight | ( | int | h | ) |
Set the height of panel/设置panel的高度
h | New height for panel title bars/panel标题栏的新高度 |
void SARibbonCategory::setPanelToolButtonIconSize | ( | const QSize & | s | ) |
Set the icon size of panel buttons, large action is not affected/设置panel按钮的icon尺寸,large action不受此尺寸影响
s | New icon size for panel buttons/panel按钮的新图标大小 |
void SARibbonCategory::setUseAnimatingScroll | ( | bool | useAnimating | ) |
Set whether to use animation when scrolling/设置滚动时是否使用动画
useAnimating | True to use animation, false to scroll directly/为true使用动画,为false直接滚动 |
void SARibbonCategory::setWheelScrollStep | ( | int | step | ) |
Set wheel scroll step (px)/设置滚轮滚动步长(px)
step | Scroll step in pixels/以像素为单位的滚动步长 |
bool SARibbonCategory::takePanel | ( | SARibbonPanel * | panel | ) |
Detach panel from SARibbonCategory management/把panel脱离SARibbonCategory的管理
panel | Panel to extract/需要提取的panel |
|
overrideprotected |
滚动事件
在内容超出category的宽度情况下,滚轮可滚动panel
event |
int SARibbonCategory::wheelScrollStep | ( | ) | const |
Wheel scroll step/滚轮的滚动步长