更新文档
This commit is contained in:
226
README.md
226
README.md
@@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#### 一、特别说明
|
## 一、特别说明
|
||||||
1. 可以选择打开QWidgetDemo.pro一次性编译所有的,也可以到目录下打开pro编译。
|
1. 可以选择打开QWidgetDemo.pro一次性编译所有的,也可以到目录下打开pro编译。
|
||||||
2. 如果发现有些子项目没有加载请打开对应目录下的.pro仔细看里面的注释。
|
2. 如果发现有些子项目没有加载请打开对应目录下的.pro仔细看里面的注释。
|
||||||
3. 编译好的可执行文件在源码同级目录下的bin目录。
|
3. 编译好的可执行文件在源码同级目录下的bin目录。
|
||||||
@@ -9,150 +9,204 @@
|
|||||||
8. **强烈推荐各位搭配Qt开发经验一起学习 [https://gitee.com/feiyangqingyun/qtkaifajingyan](https://gitee.com/feiyangqingyun/qtkaifajingyan)**
|
8. **强烈推荐各位搭配Qt开发经验一起学习 [https://gitee.com/feiyangqingyun/qtkaifajingyan](https://gitee.com/feiyangqingyun/qtkaifajingyan)**
|
||||||
9. **各位有需要购买Qt商业版可以联系Qt中国商务人员微信 zzwdkxx ,支持Qt。**
|
9. **各位有需要购买Qt商业版可以联系Qt中国商务人员微信 zzwdkxx ,支持Qt。**
|
||||||
|
|
||||||
#### 二、目录说明
|
## 二、目录说明
|
||||||
**高质量项目加粗显示**
|
**高质量项目加粗显示**
|
||||||
| 目录 | 类别 | 名称 | 描述 |
|
| 目录 | 相关 | 名称 | 描述 |
|
||||||
| :------: | :------: | :------: | :------ |
|
| :-------: | :------: | :-----------------: | :-------------------------- |
|
||||||
| control | 控件类别 | battery | **电池电量** |
|
| control | 控件相关 | battery | **电池电量** |
|
||||||
| control | 控件类别 | devicebutton | **设备按钮** |
|
| control | 控件相关 | devicebutton | **设备按钮** |
|
||||||
| control | 控件类别 | devicesizetable | 磁盘容量 |
|
| control | 控件相关 | devicesizetable | 磁盘容量 |
|
||||||
| control | 控件类别 | imageswitch | 图片开关 |
|
| control | 控件相关 | imageswitch | 图片开关 |
|
||||||
| control | 控件类别 | ipaddress | IP地址输入框 |
|
| control | 控件相关 | ipaddress | IP地址输入框 |
|
||||||
| control | 控件类别 | lightbutton | 高亮按钮 |
|
| control | 控件相关 | lightbutton | 高亮按钮 |
|
||||||
| control | 控件类别 | navbutton | **导航按钮** |
|
| control | 控件相关 | navbutton | **导航按钮** |
|
||||||
| control | 控件类别 | savelog | **日志重定向输出** |
|
| control | 控件相关 | savelog | **日志重定向输出** |
|
||||||
| control | 控件类别 | saveruntime | **运行时间记录** |
|
| control | 控件相关 | saveruntime | **运行时间记录** |
|
||||||
| control | 控件类别 | smoothcurve | 平滑曲线 |
|
| control | 控件相关 | smoothcurve | 平滑曲线 |
|
||||||
| control | 控件类别 | zhtopy | 汉字转拼音 |
|
| control | 控件相关 | zhtopy | 汉字转拼音 |
|
||||||
| tool | 工具类别 | comtool | **串口调试助手** |
|
| tool | 工具相关 | comtool | **串口调试助手** |
|
||||||
| tool | 工具类别 | nettool | **网络调试助手** |
|
| tool | 工具相关 | nettool | **网络调试助手** |
|
||||||
| tool | 工具类别 | netserver | **网络中转服务器** |
|
| tool | 工具相关 | netserver | **网络中转服务器** |
|
||||||
| tool | 工具类别 | base64helper | **图片文字转base** |
|
| tool | 工具相关 | base64helper | **图片文字转base** |
|
||||||
| tool | 工具类别 | countcode | **代码行数统计工具** |
|
| tool | 工具相关 | countcode | **代码行数统计工具** |
|
||||||
| tool | 工具类别 | emailtool | 邮件发送工具 |
|
| tool | 工具相关 | emailtool | 邮件发送工具 |
|
||||||
| tool | 工具类别 | moneytool | 存款利息计算器 |
|
| tool | 工具相关 | moneytool | 存款利息计算器 |
|
||||||
| tool | 工具类别 | pngtool | 图片警告去除工具 |
|
| tool | 工具相关 | pngtool | 图片警告去除工具 |
|
||||||
| tool | 工具类别 | keytool | **秘钥生成器** |
|
| tool | 工具相关 | keytool | **秘钥生成器** |
|
||||||
| tool | 工具类别 | keydemo | 秘钥测试程序 |
|
| tool | 工具相关 | keydemo | 秘钥测试程序 |
|
||||||
| tool | 工具类别 | livetool | 程序启动器 |
|
| tool | 工具相关 | livetool | 程序启动器 |
|
||||||
| tool | 工具类别 | livedemo | 程序启动示例 |
|
| tool | 工具相关 | livedemo | 程序启动示例 |
|
||||||
| video | 视频播放 | videobox | **视频监控布局** |
|
| video | 视频播放 | videobox | **视频监控布局** |
|
||||||
| video | 视频播放 | videopanel | **视频监控面板** |
|
| video | 视频播放 | videopanel | **视频监控面板** |
|
||||||
| video | 视频播放 | videowidget | 视频监控控件 |
|
| video | 视频播放 | videowidget | 视频监控控件 |
|
||||||
| video | 视频播放 | playffmpeg | 视频播放ffmpeg |
|
| video | 视频播放 | playffmpeg | 视频播放ffmpeg |
|
||||||
| video | 视频播放 | playvlc | 视频播放vlc |
|
| video | 视频播放 | playvlc | 视频播放vlc |
|
||||||
| video | 视频播放 | plaympv | 视频播放mpv |
|
| video | 视频播放 | plaympv | 视频播放mpv |
|
||||||
| widget | 窗体类别 | colorwidget | 颜色拾取器 |
|
| widget | 窗体相关 | colorwidget | 颜色拾取器 |
|
||||||
| widget | 窗体类别 | framelesswidget | **通用无边框窗体** |
|
| widget | 窗体相关 | framelesswidget | **通用无边框窗体** |
|
||||||
| widget | 窗体类别 | gifwidget | GIF录屏 |
|
| widget | 窗体相关 | gifwidget | GIF录屏 |
|
||||||
| widget | 窗体类别 | lunarcalendarwidget | **农历控件** |
|
| widget | 窗体相关 | lunarcalendarwidget | **农历控件** |
|
||||||
| widget | 窗体类别 | maskwidget | 通用遮罩层 |
|
| widget | 窗体相关 | maskwidget | 通用遮罩层 |
|
||||||
| widget | 窗体类别 | movewidget | 通用控件移动 |
|
| widget | 窗体相关 | movewidget | 通用控件移动 |
|
||||||
| widget | 窗体类别 | screenwidget | 屏幕截图 |
|
| widget | 窗体相关 | screenwidget | 屏幕截图 |
|
||||||
| ui | 界面美化 | flatui | 扁平化风格 |
|
| ui | 界面美化 | flatui | 扁平化风格 |
|
||||||
| ui | 界面美化 | styledemo | **三套风格样式** |
|
| ui | 界面美化 | styledemo | **三套风格样式** |
|
||||||
| ui | 界面美化 | uidemo01 | 界面美化基础示例 |
|
| ui | 界面美化 | uidemo01 | 界面美化基础示例 |
|
||||||
| ui | 界面美化 | uidemo08 | **界面美化入门示例** |
|
| ui | 界面美化 | uidemo08 | **界面美化入门示例** |
|
||||||
| ui | 界面美化 | uidemo09 | 九宫格主界面 |
|
| ui | 界面美化 | uidemo09 | 九宫格主界面 |
|
||||||
| ui | 界面美化 | uidemo10 | **扁平化主界面** |
|
| ui | 界面美化 | uidemo10 | **扁平化主界面** |
|
||||||
| ui | 界面美化 | iconhelper | **超级图形字体** |
|
| ui | 界面美化 | iconhelper | **超级图形字体** |
|
||||||
| other | 其他类别 | bgdemo | 异形窗体 |
|
| other | 其他相关 | bgdemo | 异形窗体 |
|
||||||
| other | 其他类别 | dbpage | **通用数据库翻页** |
|
| other | 其他相关 | dbpage | **通用数据库翻页** |
|
||||||
| other | 其他类别 | echartgauge | **echart图表js交互** |
|
| other | 其他相关 | echartgauge | **echart图表js交互** |
|
||||||
| other | 其他类别 | lineeditnext | 文本框回车自动跳转 |
|
| other | 其他相关 | lineeditnext | 文本框回车自动跳转 |
|
||||||
| other | 其他类别 | mouseline | 鼠标十字线 |
|
| other | 其他相关 | mouseline | 鼠标十字线 |
|
||||||
| other | 其他类别 | ntpclient | NTP校时 |
|
| other | 其他相关 | ntpclient | NTP校时 |
|
||||||
| other | 其他类别 | trayicon | 通用托盘效果 |
|
| other | 其他相关 | trayicon | 通用托盘效果 |
|
||||||
| other | 其他类别 | multobj2slot | 多对象共用槽 |
|
| other | 其他相关 | multobj2slot | 多对象共用槽 |
|
||||||
| third | 第三方类 | designer | QtDesigner设计师(Qt4) |
|
| other | 其他相关 | drawrect | 随机大量矩形 |
|
||||||
| third | 第三方类 | hotkey | 全局热键1 |
|
| third | 第三方类 | designer | QtDesigner设计师(Qt4) |
|
||||||
| third | 第三方类 | shortcut | 全局热键2 |
|
| third | 第三方类 | hotkey | 全局热键1 |
|
||||||
| third | 第三方类 | miniblink | **浏览器miniblink内核** |
|
| third | 第三方类 | shortcut | 全局热键2 |
|
||||||
| third | 第三方类 | qwtdemo | 无插件qwt示例 |
|
| third | 第三方类 | miniblink | **浏览器miniblink内核** |
|
||||||
| third | 第三方类 | qcustomplotdemo | **精美图表qcustomplot示例** |
|
| third | 第三方类 | qwtdemo | 无插件qwt示例 |
|
||||||
| netfriend | 网友提供 | astackwidget | 动态StackWidget |
|
| third | 第三方类 | qcustomplotdemo | **精美图表qcustomplot示例** |
|
||||||
| netfriend | 网友提供 | imagecropper | **头像设置工具** |
|
| netfriend | 网友提供 | astackwidget | 动态StackWidget |
|
||||||
| netfriend | 网友提供 | imageviewwindow | 图片3D效果切换 |
|
| netfriend | 网友提供 | imagecropper | **头像设置工具** |
|
||||||
| netfriend | 网友提供 | slidepuzzlewidget | 滑块图片验证码 |
|
| netfriend | 网友提供 | imageviewwindow | 图片3D效果切换 |
|
||||||
|
| netfriend | 网友提供 | slidepuzzlewidget | 滑块图片验证码 |
|
||||||
|
|
||||||
#### 三、学习群
|
## 三、效果图
|
||||||
1. **Qt技术交流群1 46679801(已满员)**
|
### 3.1 控件相关-control
|
||||||
2. **Qt技术交流群2 573199610(未满员)**
|
- 电池电量-battery
|
||||||
3. **Qt高级学习群 951393302(未满员,推荐此群)**
|
|
||||||
4. **Qt交流大会群 853086607(已满员)**
|
|
||||||
|
|
||||||
#### 四、效果图
|
|
||||||
##### 4.1、控件类别
|
|
||||||

|

|
||||||
|
- 设备按钮-devicebutton
|
||||||

|

|
||||||
|
- 磁盘容量-devicesizetable
|
||||||

|

|
||||||
|
- 图片开关-imageswitch
|
||||||

|

|
||||||
|
- IP地址输入框-ipaddress
|
||||||

|

|
||||||
|
- 高亮按钮-lightbutton
|
||||||

|

|
||||||
|
- 导航按钮-navbutton
|
||||||

|

|
||||||
|
- 日志重定向输出-savelog
|
||||||

|

|
||||||
|
- 运行时间记录-saveruntime
|
||||||

|

|
||||||
|
- 平滑曲线-smoothcurve
|
||||||

|

|
||||||
|
- 汉字转拼音-zhtopy
|
||||||

|

|
||||||
|
|
||||||
##### 4.2、工具类别
|
### 3.2 工具相关-tool
|
||||||
|
- 串口调试助手-comtool
|
||||||

|

|
||||||
|
- 网络调试助手-nettool
|
||||||

|

|
||||||
|
- 网络中转服务器-netserver
|
||||||

|

|
||||||

|

|
||||||
|
- 图片文字转base-base64helper
|
||||||

|

|
||||||
|
- 代码行数统计-countcode
|
||||||

|

|
||||||
|
- 邮件发送工具-emailtool
|
||||||

|

|
||||||
|
- 存款利息计算器-moneytool
|
||||||

|

|
||||||
|
- 图片警告去除工具-pngtool
|
||||||

|

|
||||||
|
- 秘钥生成器-keytool
|
||||||

|

|
||||||
|
- 秘钥测试程序-keydemo
|
||||||

|

|
||||||
|
- 程序启动器-livetool
|
||||||

|

|
||||||
|
- 程序启动示例-livedemo
|
||||||

|

|
||||||
|
|
||||||
##### 4.3、视频播放
|
### 3.3 视频播放-video
|
||||||
|
- 视频监控布局-videobox
|
||||||

|

|
||||||
|
- 视频监控面板-videopanel
|
||||||

|

|
||||||
|
- 视频监控控件-videowidget
|
||||||

|

|
||||||
|
- 视频播放ffmpeg-playffmpeg
|
||||||

|

|
||||||
|
- 视频播放vlc-playvlc
|
||||||

|

|
||||||
|
- 视频播放mpv-plaympv
|
||||||

|

|
||||||
|
|
||||||
##### 4.4、窗体类别
|
### 3.4 窗体相关-widget
|
||||||
|
- 颜色拾取器-colorwidget
|
||||||

|

|
||||||
|
- 通用无边框窗体-framelesswidget
|
||||||

|

|
||||||
|
- GIF录屏-gifwidget
|
||||||

|

|
||||||
|
- 农历控件-lunarcalendarwidget
|
||||||

|

|
||||||
|
- 通用遮罩层-maskwidget
|
||||||

|

|
||||||
|
- 通用控件移动-movewidget
|
||||||

|

|
||||||
|
- 屏幕截图-screenwidget
|
||||||

|

|
||||||
|
|
||||||
##### 4.5、界面美化
|
### 3.5 界面美化-ui
|
||||||
|
- 扁平化风格-flatui
|
||||||

|

|
||||||
|
- 三套风格样式-styledemo
|
||||||

|

|
||||||
|
- 界面美化基础示例-uidemo01
|
||||||

|

|
||||||
|
- 界面美化入门示例-uidemo08
|
||||||

|

|
||||||
|
- 九宫格主界面-uidemo09
|
||||||

|

|
||||||
|
- 扁平化主界面-uidemo10
|
||||||

|

|
||||||
|
- 超级图形字体-iconhelper
|
||||||

|

|
||||||

|

|
||||||
|
|
||||||
##### 4.6、其他类别
|
### 3.6 其他相关-other
|
||||||
|
- 异形窗体-bgdemo
|
||||||

|

|
||||||
|
- 通用数据库翻页-dbpage
|
||||||

|

|
||||||
|
- echart图表js交互-echartgauge
|
||||||

|

|
||||||
|
- 文本框回车自动跳转-lineeditnext
|
||||||

|

|
||||||
|
- 鼠标十字线-mouseline
|
||||||

|

|
||||||
|
- NTP校时-ntpclient
|
||||||

|

|
||||||
|
- 通用托盘效果-trayicon
|
||||||

|

|
||||||
|
- 多对象共用槽-multobj2slot
|
||||||

|

|
||||||
|
- 随机大量矩形-drawrect
|
||||||
|

|
||||||
|
|
||||||
##### 4.7、第三方类
|
### 3.7 第三方类-third
|
||||||
|
- QtDesigner设计师(Qt4)-designer
|
||||||

|

|
||||||
|
- 全局热键1-hotkey
|
||||||

|

|
||||||
|
- 全局热键2-shortcut
|
||||||

|

|
||||||
|
- 浏览器miniblink内核-miniblink
|
||||||

|

|
||||||
|
- 无插件qwt示例-qwtdemo
|
||||||

|

|
||||||
|
- 精美图表qcustomplot示例-qcustomplotdemo
|
||||||

|

|
||||||

|

|
||||||

|

|
||||||
@@ -162,8 +216,18 @@
|
|||||||

|

|
||||||

|

|
||||||
|
|
||||||
##### 4.8、网友提供
|
### 3.8 网友提供-netfriend
|
||||||
|
- 动态StackWidget-astackwidget
|
||||||

|

|
||||||
|
- 头像设置工具-imagecropper
|
||||||

|

|
||||||
|
- 图片3D效果切换-imageviewwindow
|
||||||

|

|
||||||

|
- 滑块图片验证码-slidepuzzlewidget
|
||||||
|

|
||||||
|
|
||||||
|
## 四、学习群
|
||||||
|
1. **Qt技术交流群1 46679801(已满员)**
|
||||||
|
2. **Qt技术交流群2 573199610(未满员)**
|
||||||
|
3. **Qt高级学习群 951393302(未满员,推荐此群)**
|
||||||
|
4. **Qt交流大会群 853086607(已满员)**
|
||||||
@@ -10,6 +10,10 @@ DeviceButton::DeviceButton(QWidget *parent) : QWidget(parent)
|
|||||||
{
|
{
|
||||||
canMove = false;
|
canMove = false;
|
||||||
text = "1";
|
text = "1";
|
||||||
|
|
||||||
|
colorNormal = "black";
|
||||||
|
colorAlarm = "red";
|
||||||
|
|
||||||
buttonStyle = ButtonStyle_Police;
|
buttonStyle = ButtonStyle_Police;
|
||||||
buttonColor = ButtonColor_Green;
|
buttonColor = ButtonColor_Green;
|
||||||
|
|
||||||
@@ -17,9 +21,10 @@ DeviceButton::DeviceButton(QWidget *parent) : QWidget(parent)
|
|||||||
lastPoint = QPoint();
|
lastPoint = QPoint();
|
||||||
|
|
||||||
type = "police";
|
type = "police";
|
||||||
imgName = QString(":/image/devicebutton/devicebutton_green_%1.png").arg(type);
|
imgPath = ":/image/devicebutton/devicebutton";
|
||||||
isDark = false;
|
imgName = QString("%1_green_%2.png").arg(imgPath).arg(type);
|
||||||
|
|
||||||
|
isDark = false;
|
||||||
timer = new QTimer(this);
|
timer = new QTimer(this);
|
||||||
timer->setInterval(500);
|
timer->setInterval(500);
|
||||||
connect(timer, SIGNAL(timeout()), this, SLOT(checkAlarm()));
|
connect(timer, SIGNAL(timeout()), this, SLOT(checkAlarm()));
|
||||||
@@ -119,6 +124,16 @@ QString DeviceButton::getText() const
|
|||||||
return this->text;
|
return this->text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString DeviceButton::getColorNormal() const
|
||||||
|
{
|
||||||
|
return this->colorNormal;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DeviceButton::getColorAlarm() const
|
||||||
|
{
|
||||||
|
return this->colorAlarm;
|
||||||
|
}
|
||||||
|
|
||||||
DeviceButton::ButtonStyle DeviceButton::getButtonStyle() const
|
DeviceButton::ButtonStyle DeviceButton::getButtonStyle() const
|
||||||
{
|
{
|
||||||
return this->buttonStyle;
|
return this->buttonStyle;
|
||||||
@@ -142,9 +157,9 @@ QSize DeviceButton::minimumSizeHint() const
|
|||||||
void DeviceButton::checkAlarm()
|
void DeviceButton::checkAlarm()
|
||||||
{
|
{
|
||||||
if (isDark) {
|
if (isDark) {
|
||||||
imgName = QString(":/image/devicebutton/devicebutton_black_%1.png").arg(type);
|
imgName = QString("%1_%2_%3.png").arg(imgPath).arg(colorNormal).arg(type);
|
||||||
} else {
|
} else {
|
||||||
imgName = QString(":/image/devicebutton/devicebutton_red_%1.png").arg(type);
|
imgName = QString("%1_%2_%3.png").arg(imgPath).arg(colorAlarm).arg(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
isDark = !isDark;
|
isDark = !isDark;
|
||||||
@@ -164,6 +179,22 @@ void DeviceButton::setText(const QString &text)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeviceButton::setColorNormal(const QString &colorNormal)
|
||||||
|
{
|
||||||
|
if (this->colorNormal != colorNormal) {
|
||||||
|
this->colorNormal = colorNormal;
|
||||||
|
this->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceButton::setColorAlarm(const QString &colorAlarm)
|
||||||
|
{
|
||||||
|
if (this->colorAlarm != colorAlarm) {
|
||||||
|
this->colorAlarm = colorAlarm;
|
||||||
|
this->update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DeviceButton::setButtonStyle(const DeviceButton::ButtonStyle &buttonStyle)
|
void DeviceButton::setButtonStyle(const DeviceButton::ButtonStyle &buttonStyle)
|
||||||
{
|
{
|
||||||
this->buttonStyle = buttonStyle;
|
this->buttonStyle = buttonStyle;
|
||||||
@@ -188,25 +219,35 @@ void DeviceButton::setButtonStyle(const DeviceButton::ButtonStyle &buttonStyle)
|
|||||||
|
|
||||||
void DeviceButton::setButtonColor(const DeviceButton::ButtonColor &buttonColor)
|
void DeviceButton::setButtonColor(const DeviceButton::ButtonColor &buttonColor)
|
||||||
{
|
{
|
||||||
|
//先停止定时器
|
||||||
this->buttonColor = buttonColor;
|
this->buttonColor = buttonColor;
|
||||||
isDark = false;
|
isDark = false;
|
||||||
if (timer->isActive()) {
|
if (timer->isActive()) {
|
||||||
timer->stop();
|
timer->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString color;
|
||||||
if (buttonColor == ButtonColor_Green) {
|
if (buttonColor == ButtonColor_Green) {
|
||||||
imgName = QString(":/image/devicebutton/devicebutton_green_%1.png").arg(type);
|
color = "green";
|
||||||
} else if (buttonColor == ButtonColor_Blue) {
|
} else if (buttonColor == ButtonColor_Blue) {
|
||||||
imgName = QString(":/image/devicebutton/devicebutton_blue_%1.png").arg(type);
|
color = "blue";
|
||||||
} else if (buttonColor == ButtonColor_Gray) {
|
} else if (buttonColor == ButtonColor_Gray) {
|
||||||
imgName = QString(":/image/devicebutton/devicebutton_gray_%1.png").arg(type);
|
color = "gray";
|
||||||
} else if (buttonColor == ButtonColor_Black) {
|
} else if (buttonColor == ButtonColor_Black) {
|
||||||
imgName = QString(":/image/devicebutton/devicebutton_black_%1.png").arg(type);
|
color = "black";
|
||||||
} else if (buttonColor == ButtonColor_Purple) {
|
} else if (buttonColor == ButtonColor_Purple) {
|
||||||
imgName = QString(":/image/devicebutton/devicebutton_purple_%1.png").arg(type);
|
color = "purple";
|
||||||
} else if (buttonColor == ButtonColor_Yellow) {
|
} else if (buttonColor == ButtonColor_Yellow) {
|
||||||
imgName = QString(":/image/devicebutton/devicebutton_yellow_%1.png").arg(type);
|
color = "yellow";
|
||||||
} else if (buttonColor == ButtonColor_Red) {
|
} else if (buttonColor == ButtonColor_Red) {
|
||||||
|
color = "red";
|
||||||
|
} else {
|
||||||
|
color = "green";
|
||||||
|
}
|
||||||
|
|
||||||
|
//如果和报警颜色一致则主动启动定时器切换报警颜色
|
||||||
|
imgName = QString("%1_%2_%3.png").arg(imgPath).arg(color).arg(type);
|
||||||
|
if (color == colorAlarm) {
|
||||||
checkAlarm();
|
checkAlarm();
|
||||||
if (!timer->isActive()) {
|
if (!timer->isActive()) {
|
||||||
timer->start();
|
timer->start();
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
* 设备按钮控件 作者:feiyangqingyun(QQ:517216493) 2018-07-02
|
* 设备按钮控件 作者:feiyangqingyun(QQ:517216493) 2018-07-02
|
||||||
* 1. 可设置按钮样式 圆形、警察、气泡、气泡2、消息、消息2。
|
* 1. 可设置按钮样式 圆形、警察、气泡、气泡2、消息、消息2。
|
||||||
* 2. 可设置按钮颜色 布防、撤防、报警、旁路、故障。
|
* 2. 可设置按钮颜色 布防、撤防、报警、旁路、故障。
|
||||||
* 3. 可设置报警切换。
|
* 3. 可设置报警切换及对应报警切换的颜色。
|
||||||
* 4. 可设置显示的防区号。
|
* 4. 可设置显示的防区号。
|
||||||
* 5. 可设置是否可鼠标拖动。
|
* 5. 可设置是否可鼠标拖动。
|
||||||
* 6. 发出单击和双击信号。
|
* 6. 发出单击和双击信号。
|
||||||
@@ -27,6 +27,9 @@ class DeviceButton : public QWidget
|
|||||||
Q_PROPERTY(bool canMove READ getCanMove WRITE setCanMove)
|
Q_PROPERTY(bool canMove READ getCanMove WRITE setCanMove)
|
||||||
Q_PROPERTY(QString text READ getText WRITE setText)
|
Q_PROPERTY(QString text READ getText WRITE setText)
|
||||||
|
|
||||||
|
Q_PROPERTY(QString colorNormal READ getColorNormal WRITE setColorNormal)
|
||||||
|
Q_PROPERTY(QString colorAlarm READ getColorAlarm WRITE setColorAlarm)
|
||||||
|
|
||||||
Q_PROPERTY(ButtonStyle buttonStyle READ getButtonStyle WRITE setButtonStyle)
|
Q_PROPERTY(ButtonStyle buttonStyle READ getButtonStyle WRITE setButtonStyle)
|
||||||
Q_PROPERTY(ButtonColor buttonColor READ getButtonColor WRITE setButtonColor)
|
Q_PROPERTY(ButtonColor buttonColor READ getButtonColor WRITE setButtonColor)
|
||||||
|
|
||||||
@@ -62,6 +65,10 @@ protected:
|
|||||||
private:
|
private:
|
||||||
bool canMove; //是否可移动
|
bool canMove; //是否可移动
|
||||||
QString text; //显示文字
|
QString text; //显示文字
|
||||||
|
|
||||||
|
QString colorNormal; //正常颜色
|
||||||
|
QString colorAlarm; //报警颜色
|
||||||
|
|
||||||
ButtonStyle buttonStyle; //按钮样式
|
ButtonStyle buttonStyle; //按钮样式
|
||||||
ButtonColor buttonColor; //按钮颜色
|
ButtonColor buttonColor; //按钮颜色
|
||||||
|
|
||||||
@@ -69,7 +76,9 @@ private:
|
|||||||
QPoint lastPoint; //鼠标按下最后坐标
|
QPoint lastPoint; //鼠标按下最后坐标
|
||||||
|
|
||||||
QString type; //图片末尾类型
|
QString type; //图片末尾类型
|
||||||
|
QString imgPath; //背景图片路径
|
||||||
QString imgName; //背景图片名称
|
QString imgName; //背景图片名称
|
||||||
|
|
||||||
bool isDark; //是否加深报警
|
bool isDark; //是否加深报警
|
||||||
QTimer *timer; //报警闪烁定时器
|
QTimer *timer; //报警闪烁定时器
|
||||||
|
|
||||||
@@ -80,6 +89,9 @@ public:
|
|||||||
bool getCanMove() const;
|
bool getCanMove() const;
|
||||||
QString getText() const;
|
QString getText() const;
|
||||||
|
|
||||||
|
QString getColorNormal() const;
|
||||||
|
QString getColorAlarm() const;
|
||||||
|
|
||||||
ButtonStyle getButtonStyle() const;
|
ButtonStyle getButtonStyle() const;
|
||||||
ButtonColor getButtonColor() const;
|
ButtonColor getButtonColor() const;
|
||||||
|
|
||||||
@@ -91,6 +103,11 @@ public Q_SLOTS:
|
|||||||
void setCanMove(bool canMove);
|
void setCanMove(bool canMove);
|
||||||
//设置显示文字
|
//设置显示文字
|
||||||
void setText(const QString &text);
|
void setText(const QString &text);
|
||||||
|
|
||||||
|
//设置正常颜色和报警颜色
|
||||||
|
void setColorNormal(const QString &colorNormal);
|
||||||
|
void setColorAlarm(const QString &colorAlarm);
|
||||||
|
|
||||||
//设置样式
|
//设置样式
|
||||||
void setButtonStyle(const ButtonStyle &buttonStyle);
|
void setButtonStyle(const ButtonStyle &buttonStyle);
|
||||||
//设置颜色
|
//设置颜色
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>800</width>
|
<width>900</width>
|
||||||
<height>600</height>
|
<height>600</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
BIN
other/0snap/drawrect.jpg
Normal file
BIN
other/0snap/drawrect.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 134 KiB |
13
other/drawrect/drawrect.pro
Normal file
13
other/drawrect/drawrect.pro
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
QT += core gui
|
||||||
|
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||||
|
greaterThan(QT_MAJOR_VERSION, 5): QT += core5compat
|
||||||
|
|
||||||
|
TARGET = drawrect
|
||||||
|
TEMPLATE = app
|
||||||
|
DESTDIR = $$PWD/../bin
|
||||||
|
CONFIG += warn_off
|
||||||
|
|
||||||
|
SOURCES += main.cpp
|
||||||
|
SOURCES += widget.cpp
|
||||||
|
HEADERS += widget.h
|
||||||
|
FORMS += widget.ui
|
||||||
34
other/drawrect/main.cpp
Normal file
34
other/drawrect/main.cpp
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
#pragma execution_character_set("utf-8")
|
||||||
|
|
||||||
|
#include "widget.h"
|
||||||
|
#include <QApplication>
|
||||||
|
#include <QTextCodec>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
QApplication a(argc, argv);
|
||||||
|
QFont font;
|
||||||
|
font.setFamily("Microsoft Yahei");
|
||||||
|
font.setPixelSize(13);
|
||||||
|
a.setFont(font);
|
||||||
|
|
||||||
|
#if (QT_VERSION < QT_VERSION_CHECK(5,0,0))
|
||||||
|
#if _MSC_VER
|
||||||
|
QTextCodec *codec = QTextCodec::codecForName("gbk");
|
||||||
|
#else
|
||||||
|
QTextCodec *codec = QTextCodec::codecForName("utf-8");
|
||||||
|
#endif
|
||||||
|
QTextCodec::setCodecForLocale(codec);
|
||||||
|
QTextCodec::setCodecForCStrings(codec);
|
||||||
|
QTextCodec::setCodecForTr(codec);
|
||||||
|
#else
|
||||||
|
QTextCodec *codec = QTextCodec::codecForName("utf-8");
|
||||||
|
QTextCodec::setCodecForLocale(codec);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Widget w;
|
||||||
|
//w.setWindowTitle("随机大量矩形 (QQ: 517216493 WX: feiyangqingyun)");
|
||||||
|
w.show();
|
||||||
|
|
||||||
|
return a.exec();
|
||||||
|
}
|
||||||
42
other/drawrect/widget.cpp
Normal file
42
other/drawrect/widget.cpp
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
#include "widget.h"
|
||||||
|
#include "ui_widget.h"
|
||||||
|
#include "qpainter.h"
|
||||||
|
#include "qtimer.h"
|
||||||
|
#include "qdebug.h"
|
||||||
|
|
||||||
|
Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
interval = 20;
|
||||||
|
count = 500;
|
||||||
|
this->setWindowTitle(QString("随机大量矩形 帧率: %1 数量: %2 (QQ: 517216493 WX: feiyangqingyun)").arg(1000 / interval).arg(count));
|
||||||
|
|
||||||
|
//定时器测试速度
|
||||||
|
QTimer *timer = new QTimer(this);
|
||||||
|
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
|
||||||
|
timer->start(interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget::~Widget()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Widget::paintEvent(QPaintEvent *)
|
||||||
|
{
|
||||||
|
int width = this->width();
|
||||||
|
int height = this->height();
|
||||||
|
QPainter painter(this);
|
||||||
|
|
||||||
|
QPen pen;
|
||||||
|
pen.setWidth(2);
|
||||||
|
pen.setColor(Qt::red);
|
||||||
|
painter.setPen(pen);
|
||||||
|
|
||||||
|
for (int i = 0; i < count; ++i) {
|
||||||
|
int x = rand() % width;
|
||||||
|
int y = rand() % height;
|
||||||
|
painter.drawRect(x, y, 30, 30);
|
||||||
|
}
|
||||||
|
}
|
||||||
27
other/drawrect/widget.h
Normal file
27
other/drawrect/widget.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
#ifndef WIDGET_H
|
||||||
|
#define WIDGET_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class Widget;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Widget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit Widget(QWidget *parent = 0);
|
||||||
|
~Widget();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::Widget *ui;
|
||||||
|
int interval;
|
||||||
|
int count;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // WIDGET_H
|
||||||
20
other/drawrect/widget.ui
Normal file
20
other/drawrect/widget.ui
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>Widget</class>
|
||||||
|
<widget class="QWidget" name="Widget">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>800</width>
|
||||||
|
<height>600</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<layoutdefault spacing="6" margin="11"/>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
Reference in New Issue
Block a user