原文地址::http://blog.sina.com.cn/s/blog_618a9b97010112rh.html
相关文章
1、Qt之统一的UI界面格式基调,漂亮的UI界面----http://www.cnblogs.com/appsucc/archive/2012/11/05/2754767.html
2、Qt自定义/自绘按钮类----http://download.csdn.net/detail/lh806732/3889019
3、QT自绘开关按钮----http://download.csdn.net/detail/nightrainljh/6911723
第一篇
http://blog.csdn.net/yiyaaixuexi/article/details/6706729
第二篇
http://blog.csdn.net/yiyaaixuexi/article/details/6343337
- Button::Button(QWidget
*parent) : QPushButton(parent) - {
-
//保存图片成员初始化 -
buttonPicture = new QPixmap(); -
pressPicture = new QPixmap(); -
releasePicture = new QPixmap(); -
-
//关闭按钮的默认显示 -
this -> setFlat(true); - }
-
- void
Button::setButtonPicture(QPixmap pic) - {
-
*buttonPicture = pic; -
-
this -> setIcon(QIcon(*buttonPicture)); - }
-
- void
Button::setPressPicture(QPixmap pic) - {
-
*pressPicture = pic; - }
-
- void
Button::setReleasePicture(QPixmap pic) - {
-
*releasePicture = pic; - }
-
- void
Button::set_X_Y_width_height(int x, int y, int width, int height) - {
-
this -> setIconSize(QSize(width, height)); -
this -> setGeometry(x, y, width, height); - }
-
- void
Button::mouseDoubleClickEvent(QMouseEvent *event) - {
-
//null - }
-
- void
Button::mousePressEvent (QMouseEvent *event) - {
-
this -> setIcon (QIcon(*pressPicture)); - }
-
- void
Button::mouseMoveEvent(QMouseEvent *event) - {
-
//null - }
-
-
- void
Button::mouseReleaseEvent (QMouseEvent *event) - {
-
this -> setIcon(QIcon(*releasePicture)); -
emit clicked(); - }