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

Layout manager for SARibbonPanel / SARibbonPanel的布局管理器 更多...

#include <SARibbonPanelLayout.h>

类 SARibbonPanelLayout 继承关系图:

Public 成员函数

 SARibbonPanelLayout (QWidget *p=nullptr)
 
SARibbonPanelribbonPanel () const
 Gets the SARibbonPanel that owns this layout / 获取拥有此布局的SARibbonPanel
 
void insertAction (int index, QAction *act, SARibbonPanelItem::RowProportion rp=SARibbonPanelItem::None)
 Inserts an action at a specific index / 在指定索引处插入一个action
 
void setOptionAction (QAction *action)
 Sets the option action for the panel / 为面板设置选项action
 
bool isHaveOptionAction () const
 Checks if an option action is set / 检查是否设置了选项action
 
SARibbonPanelItempanelItem (QAction *action) const
 Retrieves the SARibbonPanelItem associated with an action / 获取与action关联的SARibbonPanelItem
 
SARibbonPanelItemlastItem () const
 Gets the last item added to the layout / 获取最后添加到布局的项目
 
QWidget * lastWidget () const
 Gets the widget associated with the last item / 获取与最后一个项目关联的窗口部件
 
void move (int from, int to)
 Moves an item from one index to another / 将一个项目从一个索引移动到另一个索引
 
bool isDirty () const
 判断是否需要重新布局
 
void updateGeomArray ()
 
int indexByAction (QAction *action) const
 Finds the index of an action in the layout / 在布局中查找一个action的索引
 
int panelTitleHeight () const
 Gets the height of the panel's title / 获取面板标题的高度
 
void setPanelTitleHeight (int newTitleHeight)
 Sets the height of the panel's title / 设置面板标题的高度
 
bool isEnableShowPanelTitle () const
 Checks if the panel's title is enabled for display / 检查面板标题是否启用显示
 
void setEnableShowPanelTitle (bool on)
 Sets whether the panel's title is enabled for display / 设置面板标题是否启用显示
 
int largeButtonHeight () const
 Gets the height of large buttons / 获取大按钮的高度
 
int panelTitleSpace () const
 Gets the spacing between the title and the buttons / 获取标题与按钮之间的间距
 
void setPanelTitleSpace (int newTitleSpace)
 Sets the spacing between the title and the buttons / 设置标题与按钮之间的间距
 
SARibbonPanelLabelpanelTitleLabel () const
 Gets the panel's title label / 获取面板的标题标签
 
void setToolButtonIconSize (const QSize &s)
 Sets the default icon size for tool buttons / 设置工具按钮的默认图标尺寸
 
QSize toolButtonIconSize () const
 Gets the default icon size for tool buttons / 获取工具按钮的默认图标尺寸
 
bool isEnableWordWrap () const
 是否允许文字换行
 
qreal buttonMaximumAspectRatio () const
 按钮最大宽高比,这个系数决定按钮的最大宽度
 
void addItem (QLayoutItem *item) Q_DECL_OVERRIDE
 Adds an item to the layout (not supported) / 向布局添加一个项目(不支持)
 
QLayoutItem * itemAt (int index) const Q_DECL_OVERRIDE
 Retrieves the item at the specified index / 获取指定索引处的项目
 
QLayoutItem * takeAt (int index) Q_DECL_OVERRIDE
 Removes and returns the item at the specified index / 移除并返回指定索引处的项目
 
int count () const Q_DECL_OVERRIDE
 Gets the number of items in the layout / 获取布局中项目的数量
 
bool isEmpty () const Q_DECL_OVERRIDE
 Checks if the layout is empty / 检查布局是否为空
 
void invalidate () Q_DECL_OVERRIDE
 Invalidates the layout, marking it as dirty / 使布局失效,将其标记为“脏”
 
Qt::Orientations expandingDirections () const Q_DECL_OVERRIDE
 Returns the directions in which the layout can expand / 返回布局可以扩展的方向
 
void setGeometry (const QRect &rect) Q_DECL_OVERRIDE
 
QSize minimumSize () const Q_DECL_OVERRIDE
 
QSize sizeHint () const Q_DECL_OVERRIDE
 

Protected 成员函数

QSize optionActionButtonSize () const
 Gets the size of the option action button / 获取选项action按钮的尺寸
 
void doLayout ()
 布局所有action
 
SARibbonPanelItemcreateItem (QAction *action, SARibbonPanelItem::RowProportion rp=SARibbonPanelItem::None)
 把action转换为item
 
void updateGeomArray (const QRect &setrect)
 更新尺寸
 
void recalcExpandGeomArray (const QRect &setrect)
 
void setEnableWordWrap (bool on)
 设置文字允许换行
 
void setButtonMaximumAspectRatio (qreal fac=1.4)
 设置按钮最大宽高比,这个系数决定按钮的最大宽度
 

友元

class SARibbonPanel
 

详细描述

Layout manager for SARibbonPanel / SARibbonPanel的布局管理器

SARibbonPanelLayout is a custom QLayout subclass responsible for arranging SARibbonToolButton and other widgets within a SARibbonPanel. It handles the complex Ribbon-specific layout logic, including Large, Medium, and Small button proportions, and the optional title and option button.

SARibbonPanelLayout 是一个自定义的 QLayout 子类,负责在 SARibbonPanel 内排列 SARibbonToolButton 和其他窗口部件。它处理复杂的Ribbon特定布局逻辑,包括大、中、小按钮比例,以及可选的标题和选项按钮。

成员函数说明

◆ addItem()

void SARibbonPanelLayout::addItem ( QLayoutItem *  item)

Adds an item to the layout (not supported) / 向布局添加一个项目(不支持)

This layout only accepts items created from QAction via insertAction. Calling this function directly will result in a warning.

此布局仅接受通过 insertActionQAction 创建的项目。直接调用此函数将导致警告。

参数
itemThe layout item to add / 要添加的布局项目

◆ buttonMaximumAspectRatio()

qreal SARibbonPanelLayout::buttonMaximumAspectRatio ( ) const

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

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

◆ count()

int SARibbonPanelLayout::count ( ) const

Gets the number of items in the layout / 获取布局中项目的数量

返回
The item count / 项目数量

◆ createItem()

SARibbonPanelItem * SARibbonPanelLayout::createItem ( QAction *  action,
SARibbonPanelItem::RowProportion  rp = SARibbonPanelItem::None 
)
protected

把action转换为item

此函数参考QToolBarItem *QToolBarLayout::createItem(QAction *action)

对于普通QAction,此函数会创建SARibbonToolButton,SARibbonToolButton的类型参考SARibbonPanelItem::RowProportion,

参数
action
rp行高占比情况
返回
转换的SARibbonPanelItem
注解
每个SARibbonPanelItem最终都会携带一个widget,传入的是QWidgetAction的话,会直接使用QWidgetAction带的widget, 否则会内部生成一个SARibbonToolButton

◆ expandingDirections()

Qt::Orientations SARibbonPanelLayout::expandingDirections ( ) const

Returns the directions in which the layout can expand / 返回布局可以扩展的方向

返回
The expanding directions (always Qt::Horizontal for this layout) / 扩展方向(此布局始终为Qt::Horizontal)

◆ indexByAction()

int SARibbonPanelLayout::indexByAction ( QAction *  action) const

Finds the index of an action in the layout / 在布局中查找一个action的索引

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

◆ insertAction()

void SARibbonPanelLayout::insertAction ( int  index,
QAction *  act,
SARibbonPanelItem::RowProportion  rp = SARibbonPanelItem::None 
)

Inserts an action at a specific index / 在指定索引处插入一个action

This is the primary method for adding content to the layout. It creates a SARibbonPanelItem from the QAction and inserts it at the specified position.

这是向布局添加内容的主要方法。它从 QAction 创建一个 SARibbonPanelItem 并将其插入到指定位置。

参数
indexThe index at which to insert the action / 插入action的索引
actThe action to insert / 要插入的action
rpThe row proportion for the action / action的行占比

◆ invalidate()

void SARibbonPanelLayout::invalidate ( )

Invalidates the layout, marking it as dirty / 使布局失效,将其标记为“脏”

This forces a recalculation of the layout geometry on the next update.

这会强制在下次更新时重新计算布局几何形状。

◆ isDirty()

bool SARibbonPanelLayout::isDirty ( ) const

判断是否需要重新布局

返回

◆ isEmpty()

bool SARibbonPanelLayout::isEmpty ( ) const

Checks if the layout is empty / 检查布局是否为空

返回
true if the layout has no items; otherwise false / 如果布局没有项目则返回true;否则返回false

◆ isEnableShowPanelTitle()

bool SARibbonPanelLayout::isEnableShowPanelTitle ( ) const

Checks if the panel's title is enabled for display / 检查面板标题是否启用显示

返回
true if the title is enabled; otherwise false / 如果标题启用则返回true;否则返回false
参见
setEnableShowPanelTitle

◆ isEnableWordWrap()

bool SARibbonPanelLayout::isEnableWordWrap ( ) const

是否允许文字换行

返回

◆ isHaveOptionAction()

bool SARibbonPanelLayout::isHaveOptionAction ( ) const

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

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

◆ itemAt()

QLayoutItem * SARibbonPanelLayout::itemAt ( int  index) const

Retrieves the item at the specified index / 获取指定索引处的项目

参数
indexThe index of the item / 项目的索引
返回
The layout item, or nullptr if index is invalid / 布局项目,如果索引无效则返回nullptr

◆ largeButtonHeight()

int SARibbonPanelLayout::largeButtonHeight ( ) const

Gets the height of large buttons / 获取大按钮的高度

返回
The large button height / 大按钮高度

◆ lastItem()

SARibbonPanelItem * SARibbonPanelLayout::lastItem ( ) const

Gets the last item added to the layout / 获取最后添加到布局的项目

返回
The last item, or nullptr if the layout is empty / 最后一个项目,如果布局为空则返回nullptr

◆ lastWidget()

QWidget * SARibbonPanelLayout::lastWidget ( ) const

Gets the widget associated with the last item / 获取与最后一个项目关联的窗口部件

返回
The widget, or nullptr if not found / 窗口部件,如果未找到则返回nullptr

◆ move()

void SARibbonPanelLayout::move ( int  from,
int  to 
)

Moves an item from one index to another / 将一个项目从一个索引移动到另一个索引

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

◆ optionActionButtonSize()

QSize SARibbonPanelLayout::optionActionButtonSize ( ) const
protected

Gets the size of the option action button / 获取选项action按钮的尺寸

返回
The button's size / 按钮的尺寸

◆ panelItem()

SARibbonPanelItem * SARibbonPanelLayout::panelItem ( QAction *  action) const

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

参数
actionThe action to query / 要查询的action
返回
The associated item, or nullptr if not found / 关联的项目,如果未找到则返回nullptr

◆ panelTitleHeight()

int SARibbonPanelLayout::panelTitleHeight ( ) const

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

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

◆ panelTitleLabel()

SARibbonPanelLabel * SARibbonPanelLayout::panelTitleLabel ( ) const

Gets the panel's title label / 获取面板的标题标签

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

◆ panelTitleSpace()

int SARibbonPanelLayout::panelTitleSpace ( ) const

Gets the spacing between the title and the buttons / 获取标题与按钮之间的间距

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

◆ recalcExpandGeomArray()

void SARibbonPanelLayout::recalcExpandGeomArray ( const QRect &  setrect)
protected

< 原来的列宽

< 列的最大宽度

< 扩展后列的宽度

◆ ribbonPanel()

SARibbonPanel * SARibbonPanelLayout::ribbonPanel ( ) const

Gets the SARibbonPanel that owns this layout / 获取拥有此布局的SARibbonPanel

返回
A pointer to the parent SARibbonPanel, or nullptr if not found / 指向父SARibbonPanel的指针,如果未找到则返回nullptr

◆ setButtonMaximumAspectRatio()

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

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

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

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

◆ setEnableShowPanelTitle()

void SARibbonPanelLayout::setEnableShowPanelTitle ( bool  on)

Sets whether the panel's title is enabled for display / 设置面板标题是否启用显示

参数
onIf true, the title is enabled / 如果为true,则启用标题
参见
isEnableShowPanelTitle

◆ setEnableWordWrap()

void SARibbonPanelLayout::setEnableWordWrap ( bool  on)
protected

设置文字允许换行

参数
enableWordWrap

◆ setOptionAction()

void SARibbonPanelLayout::setOptionAction ( QAction *  action)

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

The option action is displayed as a 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以移除

◆ setPanelTitleHeight()

void SARibbonPanelLayout::setPanelTitleHeight ( int  newTitleHeight)

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

参数
newTitleHeightThe new title height / 新的标题高度
参见
panelTitleHeight

◆ setPanelTitleSpace()

void SARibbonPanelLayout::setPanelTitleSpace ( int  newTitleSpace)

Sets the spacing between the title and the buttons / 设置标题与按钮之间的间距

参数
newTitleSpaceThe new spacing value / 新的间距值
参见
panelTitleSpace

◆ setToolButtonIconSize()

void SARibbonPanelLayout::setToolButtonIconSize ( const QSize &  s)

Sets the default icon size for tool buttons / 设置工具按钮的默认图标尺寸

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

◆ takeAt()

QLayoutItem * SARibbonPanelLayout::takeAt ( int  index)

Removes and returns the item at the specified index / 移除并返回指定索引处的项目

参数
indexThe index of the item to remove / 要移除的项目的索引
返回
The removed layout item, or nullptr if index is invalid / 被移除的布局项目,如果索引无效则返回nullptr

◆ toolButtonIconSize()

QSize SARibbonPanelLayout::toolButtonIconSize ( ) const

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

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

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