【1】Custom.cpp

 #include "CustomButton.h"

 CustomButton::CustomButton(QWidget* parent)
: QPushButton(parent)
, m_bCheckState(false)
{
setFixedSize(, );
setFlat(true);
} void CustomButton::mousePressEvent(QMouseEvent *event)
{
if (m_bCheckState)
{
m_bCheckState = false;
setStyleSheet("QPushButton{background-image:url(:/new/image/mute.png);border:none;}");
}
else
{
m_bCheckState = true;
setStyleSheet("QPushButton{background-image:url(:/new/image/unmute.png);border:none;}");
} return QPushButton::mousePressEvent(event);
}

【2】Custom.h

 #ifndef CUSTOMBUTTON_H
#define CUSTOMBUTTON_H #include <QPushButton> class CustomButton : public QPushButton
{
public:
CustomButton(QWidget* parent = Q_NULLPTR); protected:
void mousePressEvent(QMouseEvent* event); private:
bool m_bCheckState;
}; #endif // CUSTOMBUTTON_H

【3】pro

#-------------------------------------------------
#
# Project created by QtCreator
#
#------------------------------------------------- QT += core gui greaterThan(QT_MAJOR_VERSION, ): QT += widgets TARGET = TestState
TEMPLATE = app # The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0. SOURCES += main.cpp\
widget.cpp \
CustomButton.cpp HEADERS += widget.h \
CustomButton.h FORMS += widget.ui RESOURCES += \
image.qrc

【4】其他默认文件

Good Good  Study, Day Day Up.

顺序 选择  循环 总结

最新文章

  1. cmd常用命令
  2. Socket 通讯
  3. Ubuntu Linux上安装oracle jdk
  4. VCC、VDD、VEE、VSS等有关电源标注的区别
  5. 转:LayoutInflater作用及使用
  6. Windows下管理Python安装包
  7. 获取Android设备屏幕分辨率
  8. sed 批量替换多个文件里的某个字符/串
  9. 矢量做图组件OTGisX的使用(类似Mapbase)
  10. 日历的问题C语言,C++(boost),python,Javascript,Java和Matlab实现
  11. [ An Ac a Day ^_^ ] [kuangbin带你飞]专题六 最小生成树 POJ 1251 Jungle Roads
  12. (转)详解JS位置、宽高属性之一:offset系列
  13. 【Python】 hash值计算 hashlib &amp; hmac
  14. RxSwift(一)
  15. R语言预测实战(游浩麟)笔记1
  16. 厉害了,Spring Cloud for Alibaba 来了!
  17. IP和网段及子网掩码基础知识
  18. JS--我发现,原来你是这样的JS(引用类型不简单[下篇],基本包装类型与个体内置对象)
  19. Python基础数据类型-字典(dict)
  20. s3express截图安装教程

热门文章

  1. MUI框架a链接href跳转失效解决方法,解决MUI页面不会滚动的方法
  2. MovieLens电影数据分析
  3. redis设置bind
  4. 批量查询&quot;_mget&quot;
  5. 注意:WordPress栏目别名slug不要设为p
  6. 2018天猫双11各类目品牌成交额top10排行榜
  7. wamp3.1.0下载地址
  8. 报错解决——SSL: CERTIFICATE_VERIFY_FAILED
  9. 20165236实验一 Java开发环境的熟悉
  10. Kinect2.0获取数据