DtkWidget 5.6.0.2
DTK Widget module
Public 类型 | 信号 | Public 成员函数 | Protected 成员函数 | 属性 | 所有成员列表
Dtk::Widget::DImageButton类 参考

The DImageButton class provides an easy way to create image based buttons. 更多...

类 Dtk::Widget::DImageButton 继承关系图:
Inheritance graph
[图例]
Dtk::Widget::DImageButton 的协作图:
Collaboration graph
[图例]

Public 类型

enum  State {
  Normal , Hover , Press , Checked ,
  Disabled
}
 

信号

void clicked ()
 当按钮被点击时会发出该信号
 
void checkedChanged (bool checked)
 当按钮的选择状态 checked 发生改变时会发出该信号
 
void stateChanged ()
 当按钮的状态发生变化时会发出该信号
 

Public 成员函数

 DImageButton (QWidget *parent=0)
 DImageButton的默认构造函数 更多...
 
 DImageButton (const QString &normalPic, const QString &hoverPic, const QString &pressPic, QWidget *parent=0)
 这是重载的构造函数 更多...
 
 DImageButton (const QString &normalPic, const QString &hoverPic, const QString &pressPic, const QString &checkedPic, QWidget *parent=0)
 DImageButton::DImageButton This is an overloaded function. 更多...
 
void setEnabled (bool enabled)
 设置是否启用按钮的功能 更多...
 
void setDisabled (bool disabled)
 设置是否禁用按钮的功能 更多...
 
void setChecked (bool flag)
 设置按钮的选中状态 更多...
 
void setCheckable (bool flag)
 设置按钮是否可以被选中 更多...
 
bool isChecked () const
 返回按钮是否是选中状态 更多...
 
bool isCheckable () const
 这个方法会返回按钮是否可以被选中 更多...
 
void setNormalPic (const QString &normalPic)
 该方法用来设置默认状态下的图片 更多...
 
void setHoverPic (const QString &hoverPic)
 设置鼠标在控件上时的图片 更多...
 
void setPressPic (const QString &pressPic)
 设置鼠标按下的图片 更多...
 
void setCheckedPic (const QString &checkedPic)
 设置选中状态下的图片 更多...
 
void setDisabledPic (const QString &disabledPic)
 设置禁用状态下的图片 更多...
 
const QString getNormalPic () const
 返回默认状态的图片路径 更多...
 
const QString getHoverPic () const
 返回鼠标在按钮上时的图片路径 更多...
 
const QString getPressPic () const
 返回鼠标按下时的图片 更多...
 
const QString getCheckedPic () const
 返回选中状态时的图片 更多...
 
const QString getDisabledPic () const
 返回禁用状态下的图片 更多...
 
void setState (State state)
 设置当前的按钮状态 更多...
 
State getState () const
 DImageButton::getState 更多...
 

Protected 成员函数

 DImageButton (DImageButtonPrivate &q, QWidget *parent)
 
void enterEvent (QEvent *event) Q_DECL_OVERRIDE
 
void leaveEvent (QEvent *event) Q_DECL_OVERRIDE
 
void mousePressEvent (QMouseEvent *event) Q_DECL_OVERRIDE
 
void mouseReleaseEvent (QMouseEvent *event) Q_DECL_OVERRIDE
 
void mouseMoveEvent (QMouseEvent *event) Q_DECL_OVERRIDE
 

属性

QString normalPic
 当前的默认状态图片 更多...
 
QString hoverPic
 This property holds the path of the image used as the hover state.
更多...
 
QString pressPic
 This property holds the path of the image used as the pressed state. 更多...
 
QString checkedPic
 This property holds the path of the image used as the checked state. 更多...
 
QString disabledPic
 禁用状态下的图片 更多...
 
bool checked
 返回按钮现在是否为选中状态 更多...
 
bool checkable
 这个方法会返回按钮是否可以被选中 更多...
 

详细描述

The DImageButton class provides an easy way to create image based buttons.

\inmodule dtkwidget

在Deepin的程序设计中,用到了大量基于图片的按钮,而Qt的QPushButton不能方便的只使用图片, 每个项目都存在相同的自绘图片的按钮控件,所以Dtk提供了基于图片来构建的按钮。

A DImageButton has four states: normal, hover, pressed and checked, developers should provide at least the normal state image to get it to work properly.

DImageButton 五个状态:

DImageButton *button = new DImageButton(":/normal.png", ":/hover.png", ":/press.png", this);
...
connect(button, &DImageButton::clicked, ...);
DImageButton(QWidget *parent=0)
DImageButton的默认构造函数
Definition: dimagebutton.cpp:82
void clicked()
当按钮被点击时会发出该信号

构造及析构函数说明

◆ DImageButton() [1/3]

Dtk::Widget::DImageButton::DImageButton ( QWidget *  parent = 0)

DImageButton的默认构造函数

DImageButton::DImageButton constructs an instance of DImageButton

parent is the parent widget that the button will be attached to.

◆ DImageButton() [2/3]

Dtk::Widget::DImageButton::DImageButton ( const QString normalPic,
const QString hoverPic,
const QString pressPic,
QWidget *  parent = 0 
)

这是重载的构造函数

DImageButton::DImageButton This is an overloaded function.

通过图片来初始化按钮 It's convinient to provide the images that used at the initialize stage.

normalPic 默认状态下的图片 normalPic is the path of image to be used as the normal state. hoverPic 鼠标在控件上的图片 hoverPic is the path of image to be used as the hover state. pressPic 鼠标按下的图片 pressPic is the path of image to be used as the pressed state. parent is the parent widget that the button will be attached to.

◆ DImageButton() [3/3]

Dtk::Widget::DImageButton::DImageButton ( const QString normalPic,
const QString hoverPic,
const QString pressPic,
const QString checkedPic,
QWidget *  parent = 0 
)

DImageButton::DImageButton This is an overloaded function.

这是重载的构造函数 通过图片来初始化按钮 It's convinient to provide the images that used at the initialize stage.

normalPic 默认的图片 normalPic is the path of image to be used as the normal state. hoverPic 鼠标在控件上的图片 hoverPic is the path of image to be used as the hover state. pressPic 鼠标按下的图片 pressPic is the path of image to be used as the pressed state. checkedPic 选中时的图片 checkedPic is the path of image to be used as the checked state. parent is the parent widget that the button will be attached to.

成员函数说明

◆ getCheckedPic()

const QString Dtk::Widget::DImageButton::getCheckedPic ( ) const

返回选中状态时的图片

参见
DImageButton::setCheckedPic
DImageButton::checkedPic
返回
const QString 图片路径

◆ getDisabledPic()

const QString Dtk::Widget::DImageButton::getDisabledPic ( ) const

返回禁用状态下的图片

参见
DImageButton::setDisabledPic
DImageButton::disabledPic
返回
const QString 图片路径

◆ getHoverPic()

const QString Dtk::Widget::DImageButton::getHoverPic ( ) const

返回鼠标在按钮上时的图片路径

参见
DImageButton::setHoverPic
DImageButton::hoverPic
返回
const QString 图片路径

◆ getNormalPic()

const QString Dtk::Widget::DImageButton::getNormalPic ( ) const

返回默认状态的图片路径

参见
DImageButton::setNormalPic
DImageButton::normalPic
返回
const QString 默认状态图片的路径

◆ getPressPic()

const QString Dtk::Widget::DImageButton::getPressPic ( ) const

返回鼠标按下时的图片

参见
DImageButton::pressPic
DImageButton::setPressPic
返回
const QString 图片路径

◆ getState()

DImageButton::State Dtk::Widget::DImageButton::getState ( ) const

DImageButton::getState

返回当前的按钮状态

参见
DImageButton::setState
DImageButton::stateChanged
返回
the state that the DImageButton is in.
DImageButton::State

◆ isCheckable()

bool Dtk::Widget::DImageButton::isCheckable ( ) const

这个方法会返回按钮是否可以被选中

参见
DImageButton::setCheckable
DImageButton::checkable
返回
true
false

◆ isChecked()

bool Dtk::Widget::DImageButton::isChecked ( ) const

返回按钮是否是选中状态

参见
DImageButton::setChecked
DImageButton::checkedChanged
返回
true 选中状态
false 不是选中状态

◆ setCheckable()

void Dtk::Widget::DImageButton::setCheckable ( bool  flag)

设置按钮是否可以被选中

该方法默认值为false,如果要开启选中效果,则需要设置为True。

参见
DImageButton::checkable
DImageButton::isCheckable

flag

◆ setChecked()

void Dtk::Widget::DImageButton::setChecked ( bool  flag)

设置按钮的选中状态

如果DImageButton::setCheckable()没有被设置为true,则当前方法不可用。

flag

参见
DImageButton::setCheckable
DImageButton::isChecked
DImageButton::checkedChanged

◆ setCheckedPic()

void Dtk::Widget::DImageButton::setCheckedPic ( const QString checkedPicPixmap)

设置选中状态下的图片

参见
DImageButton::checkedPic
DImageButton::getCheckedPic

checkedPicPixmap 图片的访问地址

◆ setDisabled()

void Dtk::Widget::DImageButton::setDisabled ( bool  disabled)

设置是否禁用按钮的功能

该方法和 DImageButton::setEnabled() 方法的作用相反,设置为True时则按钮的功能不可用,不能被点击和选中。

参见
setEnabled()

disabled

◆ setDisabledPic()

void Dtk::Widget::DImageButton::setDisabledPic ( const QString disabledPicPixmap)

设置禁用状态下的图片

参见
DImageButton::disabledPic
DImageButton::getDisabledPic

disabledPicPixmap 图片的访问地址

◆ setEnabled()

void Dtk::Widget::DImageButton::setEnabled ( bool  enabled)

设置是否启用按钮的功能

该方法和 DImageButton::setDisabled() 方法的作用相反,设置为False时则按钮的功能不可用,不能被点击和选中。

参见
setDisabled()
isEnabled()

enabled

◆ setHoverPic()

void Dtk::Widget::DImageButton::setHoverPic ( const QString hoverPicPixmap)

设置鼠标在控件上时的图片

参见
DImageButton::hoverPic
DImageButton::getHoverPic

hoverPicPixmap 图片的访问地址

◆ setNormalPic()

void Dtk::Widget::DImageButton::setNormalPic ( const QString normalPicPixmap)

该方法用来设置默认状态下的图片

参见
DImageButton::normalPic
DImageButton::getNormalPic

normalPicPixmap 图片的访问地址

◆ setPressPic()

void Dtk::Widget::DImageButton::setPressPic ( const QString pressPicPixmap)

设置鼠标按下的图片

参见
DImageButton::pressPic
DImageButton::getPressPic

pressPicPixmap 图片的访问地址

◆ setState()

void Dtk::Widget::DImageButton::setState ( DImageButton::State  state)

设置当前的按钮状态

DImageButton::setState change the image by state

state 当前的状态 state: see DImageButton::State

参见
DImageButton::getState
DImageButton::stateChanged()

属性说明

◆ checkable

Dtk::Widget::DImageButton::checkable
readwrite

这个方法会返回按钮是否可以被选中

This property indicates the DImageButton can be checked or not.

参见
DImageButton::setCheckable
DImageButton::isCheckable
返回
true 可以被选中
false 不可以被选中

◆ checked

Dtk::Widget::DImageButton::checked
readwrite

返回按钮现在是否为选中状态

This property indicates the DImageButton is in checked state of not.

参见
DImageButton::setChecked
DImageButton::checkedChanged
返回
true 选中
false 未选中

◆ checkedPic

Dtk::Widget::DImageButton::checkedPic
readwrite

This property holds the path of the image used as the checked state.

选中状态时的图片

返回
const QString 图片路径
参见
DImageButton::setCheckedPic
DImageButton::getCheckedPic

◆ disabledPic

Dtk::Widget::DImageButton::disabledPic
readwrite

禁用状态下的图片

参见
DImageButton::setDisabledPic
DImageButton::getDisabledPic
返回
const QString 图片路径

◆ hoverPic

Dtk::Widget::DImageButton::hoverPic
readwrite

This property holds the path of the image used as the hover state.

返回鼠标在控件上时的图片路径

参见
DImageButton::setHoverPic
DImageButton::getHoverPic
返回
const QString 图片路径

◆ normalPic

Dtk::Widget::DImageButton::normalPic
readwrite

当前的默认状态图片

This property holds the path of the image used as the normal state.

参见
DImageButton::setNormalPic
DImageButton::getNormalPic
返回
const QString

◆ pressPic

Dtk::Widget::DImageButton::pressPic
readwrite

This property holds the path of the image used as the pressed state.

设置的鼠标按下时的图片

参见
DImageButton::setPressPic
DImageButton::getPressPic
返回
const QString 图片路径

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