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

Refer to the color setting button in the office, which can display the color below the icon(参考office的颜色设置按钮,可以显示颜色在图标下方) 更多...

#include <SARibbonColorToolButton.h>

类 SARibbonColorToolButton 继承关系图:
SARibbonToolButton

class  PrivateData
 

Public 类型

enum  ColorStyle { ColorUnderIcon , ColorFillToIcon }
 颜色样式 更多...
 
- Public 类型 继承自 SARibbonToolButton
enum  RibbonButtonType { LargeButton , SmallButton }
 Button type enumeration / 按钮样式枚举 更多...
 

Public 槽

void setColor (const QColor &c)
 设置按钮的颜色
 

信号

void colorClicked (const QColor &color, bool checked=false)
 颜色被点击的响应
 
void colorChanged (const QColor &color)
 颜色改变信号
 

Public 成员函数

 SARibbonColorToolButton (QWidget *parent=nullptr)
 
 SARibbonColorToolButton (QAction *defaultAction, QWidget *parent=nullptr)
 
QColor color () const
 获取按钮维护的颜色
 
void setColorStyle (ColorStyle s)
 设置颜色显示的样式
 
ColorStyle colorStyle () const
 颜色显示的样式
 
SAColorMenusetupStandardColorMenu ()
 建立标准的颜色菜单
 
- Public 成员函数 继承自 SARibbonToolButton
 SARibbonToolButton (QWidget *parent=nullptr)
 
 SARibbonToolButton (QAction *defaultAction, QWidget *parent=nullptr)
 
RibbonButtonType buttonType () const
 Gets the current button type (LargeButton or SmallButton) / 获取当前按钮的类型(大按钮或小按钮)
 
void setButtonType (const RibbonButtonType &buttonType)
 Sets the button type to LargeButton or SmallButton / 设置按钮类型为大按钮或小按钮
 
bool isSmallRibbonButton () const
 Checks if the button is a small ribbon button / 判断按钮是否为小Ribbon按钮
 
bool isLargeRibbonButton () const
 Checks if the button is a large ribbon button / 判断按钮是否为大Ribbon按钮
 
int spacing () const
 Gets the current spacing value / 获取当前的间距值
 
void setSpacing (int v)
 Sets the spacing between elements and the border / 设置元素与边框之间的间距
 
void updateRect ()
 Forces an update of the internal layout rectangles / 强制更新内部布局矩形
 
void setLayoutFactor (const LayoutFactor &fac)
 Sets the layout factor for fine-tuning the button's appearance / 设置布局系数以微调按钮外观
 
const LayoutFactorlayoutFactor () const
 Gets a const reference to the current layout factor / 获取当前布局系数的常量引用
 
LayoutFactorlayoutFactor ()
 Gets a mutable reference to the current layout factor / 获取当前布局系数的可变引用
 
void setEnableWordWrap (bool on)
 Enables or disables automatic text wrapping for large buttons / 为大按钮启用或禁用自动文字换行
 
bool isEnableWordWrap ()
 Checks if automatic text wrapping is enabled / 检查是否启用了自动文字换行
 
void setButtonMaximumAspectRatio (qreal v=1.4)
 Sets the button's maximum aspect ratio (width/height) / 设置按钮的最大宽高比
 
qreal buttonMaximumAspectRatio () const
 Gets the button's maximum aspect ratio (width/height) / 获取按钮的最大宽高比
 
void invalidateSizeHint ()
 Invalidates the cached size hint / 使缓存的size hint失效
 
virtual QSize sizeHint () const Q_DECL_OVERRIDE
 Returns the recommended size for the button / 返回按钮的推荐尺寸
 
virtual QSize minimumSizeHint () const Q_DECL_OVERRIDE
 Returns the recommended minimum size for the button / 返回按钮的推荐最小尺寸
 

Protected 成员函数

void paintIcon (QPainter &p, const QStyleOptionToolButton &opt, const QRect &iconDrawRect)
 重写paintIcon函数,把颜色加到icon下面
 
- Protected 成员函数 继承自 SARibbonToolButton
virtual void paintEvent (QPaintEvent *e) Q_DECL_OVERRIDE
 
virtual void resizeEvent (QResizeEvent *e) Q_DECL_OVERRIDE
 在resizeevent计算绘图所需的尺寸,避免在绘图过程中实时绘制提高效率
 
virtual void mouseMoveEvent (QMouseEvent *e) Q_DECL_OVERRIDE
 鼠标移动事件
 
virtual void mousePressEvent (QMouseEvent *e) Q_DECL_OVERRIDE
 SARibbonToolButton::mousePressEvent
 
virtual void mouseReleaseEvent (QMouseEvent *e) Q_DECL_OVERRIDE
 
virtual void focusOutEvent (QFocusEvent *e) Q_DECL_OVERRIDE
 
virtual void leaveEvent (QEvent *e) Q_DECL_OVERRIDE
 
virtual bool hitButton (const QPoint &pos) const Q_DECL_OVERRIDE
 
virtual bool event (QEvent *e) Q_DECL_OVERRIDE
 
virtual void changeEvent (QEvent *e) Q_DECL_OVERRIDE
 
virtual void actionEvent (QActionEvent *e) Q_DECL_OVERRIDE
 
virtual void paintButton (QPainter &p, const QStyleOptionToolButton &opt)
 Paints the button's background and frame / 绘制按钮的背景和边框
 
virtual void paintText (QPainter &p, const QStyleOptionToolButton &opt, const QRect &textDrawRect)
 Paints the button's text / 绘制按钮的文字
 
virtual void paintIndicator (QPainter &p, const QStyleOptionToolButton &opt, const QRect &indicatorDrawRect)
 Paints the button's indicator (e.g., dropdown arrow) / 绘制按钮的指示器(例如下拉箭头)
 

详细描述

Refer to the color setting button in the office, which can display the color below the icon(参考office的颜色设置按钮,可以显示颜色在图标下方)

成员枚举类型说明

◆ ColorStyle

颜色样式

枚举值
ColorUnderIcon 

颜色在icon下方,这个要求必须设置icon

ColorFillToIcon 

颜色作为icon,这个模式下在setColor会自动生成一个颜色icon替换掉原来的icon,因此setIcon函数没有作用

成员函数说明

◆ color()

QColor SARibbonColorToolButton::color ( ) const

获取按钮维护的颜色

返回

◆ colorChanged

void SARibbonColorToolButton::colorChanged ( const QColor &  color)
signal

颜色改变信号

参数
color

◆ colorClicked

void SARibbonColorToolButton::colorClicked ( const QColor &  color,
bool  checked = false 
)
signal

颜色被点击的响应

参数
color

◆ colorStyle()

SARibbonColorToolButton::ColorStyle SARibbonColorToolButton::colorStyle ( ) const

颜色显示的样式

返回

◆ paintIcon()

void SARibbonColorToolButton::paintIcon ( QPainter &  p,
const QStyleOptionToolButton &  opt,
const QRect &  iconDrawRect 
)
protectedvirtual

重写paintIcon函数,把颜色加到icon下面

参数
p
opt
iconDrawRect

重载 SARibbonToolButton .

◆ setColor

void SARibbonColorToolButton::setColor ( const QColor &  c)
slot

设置按钮的颜色

此时会生成一个新的icon

注解
会发射
参见
colorChanged 信号
参数
c

◆ setColorStyle()

void SARibbonColorToolButton::setColorStyle ( SARibbonColorToolButton::ColorStyle  s)

设置颜色显示的样式

参数
s

◆ setupStandardColorMenu()

SAColorMenu * SARibbonColorToolButton::setupStandardColorMenu ( )

建立标准的颜色菜单

返回

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