DtkWidget 5.6.0.2
DTK Widget module
|
The DImageButton class provides an easy way to create image based buttons. 更多...
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 五个状态:
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.
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.
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.
const QString Dtk::Widget::DImageButton::getCheckedPic | ( | ) | const |
const QString Dtk::Widget::DImageButton::getDisabledPic | ( | ) | const |
const QString Dtk::Widget::DImageButton::getHoverPic | ( | ) | const |
const QString Dtk::Widget::DImageButton::getNormalPic | ( | ) | const |
const QString Dtk::Widget::DImageButton::getPressPic | ( | ) | const |
DImageButton::State Dtk::Widget::DImageButton::getState | ( | ) | const |
返回当前的按钮状态
bool Dtk::Widget::DImageButton::isCheckable | ( | ) | const |
bool Dtk::Widget::DImageButton::isChecked | ( | ) | const |
void Dtk::Widget::DImageButton::setCheckable | ( | bool | flag | ) |
设置按钮是否可以被选中
该方法默认值为false,如果要开启选中效果,则需要设置为True。
flag
void Dtk::Widget::DImageButton::setChecked | ( | bool | flag | ) |
设置按钮的选中状态
如果DImageButton::setCheckable()没有被设置为true,则当前方法不可用。
flag
void Dtk::Widget::DImageButton::setCheckedPic | ( | const QString & | checkedPicPixmap | ) |
void Dtk::Widget::DImageButton::setDisabled | ( | bool | disabled | ) |
void Dtk::Widget::DImageButton::setDisabledPic | ( | const QString & | disabledPicPixmap | ) |
void Dtk::Widget::DImageButton::setEnabled | ( | bool | enabled | ) |
设置是否启用按钮的功能
该方法和 DImageButton::setDisabled() 方法的作用相反,设置为False时则按钮的功能不可用,不能被点击和选中。
enabled
void Dtk::Widget::DImageButton::setHoverPic | ( | const QString & | hoverPicPixmap | ) |
void Dtk::Widget::DImageButton::setNormalPic | ( | const QString & | normalPicPixmap | ) |
void Dtk::Widget::DImageButton::setPressPic | ( | const QString & | pressPicPixmap | ) |
void Dtk::Widget::DImageButton::setState | ( | DImageButton::State | state | ) |
设置当前的按钮状态
DImageButton::setState change the image by state
state 当前的状态 state: see DImageButton::State
|
readwrite |
这个方法会返回按钮是否可以被选中
This property indicates the DImageButton can be checked or not.
|
readwrite |
返回按钮现在是否为选中状态
This property indicates the DImageButton is in checked state of not.
|
readwrite |
|
readwrite |
|
readwrite |
This property holds the path of the image used as the hover state.
返回鼠标在控件上时的图片路径
|
readwrite |
|
readwrite |
This property holds the path of the image used as the pressed state.
设置的鼠标按下时的图片