feat:统计界面

This commit is contained in:
徐超 2024-11-05 17:48:05 +08:00
parent d5fb5c64dd
commit ac69d356e8
9 changed files with 620 additions and 363 deletions

View File

@ -9,7 +9,7 @@ QLable#label_splite{font: bold 14px;}
QWidget#widgetTitle{background-color:#061f65;}
QWidget#baseWidget{background-color:#EE013B6B;border-radius: 11px;}
QComboBox{background-color: transparent; selection-background-color: transparent; color:#ffffff; font-size: 14px; min-height: 20px; selection-text-align: right;border:0px solid}
QComboBox{background-color: transparent; selection-background-color: transparent; color:#ffffff; font-size: 14px; min-height: 20px; border:0px solid}
QComboBox::down-arrow{ image:url(:/component/ZDateEdit/Resources/ComboBoxArrow.png); }
QComboBox::down-arrow:on{ top: 1px; left: 1px; } QComboBox::drop-down{ width: 26px; border:none; }
QComboBox QAbstractItemView {border: none; outline:0px;} QComboBox QAbstractItemView::item{ height: 26px; min-height:26px;}

View File

@ -8,14 +8,21 @@
#include <QTimer>
MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent), ui(new Ui::MainWindow) {
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
this->setWindowFlag(Qt::FramelessWindowHint);
this->setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint |
Qt::WindowMinimizeButtonHint);
this->setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint);
ui->widget_head->installEventFilter(this);
m_systemSetting = new QSettings("system.ini", QSettings::IniFormat);
calendarLoopPlay();
setSystemTitle();
setBeltWarnInfoTextEditStyle();
addcoalDistributChart();
@ -29,7 +36,39 @@ MainWindow::MainWindow(QWidget *parent)
MainWindow::~MainWindow() { delete ui; }
void MainWindow::addBeltWarnInfoToTextEdit(const QString &consoleInfo) {
bool MainWindow::eventFilter(QObject* watched, QEvent* event)
{
// 处理鼠标按下、释放和移动事件
if (watched == ui->widget_head) {
QMouseEvent* mouseEvent = static_cast<QMouseEvent*>(event);
if (mouseEvent->type() == QEvent::MouseButtonPress) {
if (mouseEvent->button() == Qt::LeftButton) {
m_mousePressed = true; // 启动拖拽
m_mousePoint = mouseEvent->globalPos() - this->pos();
this->setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint | Qt::Window | Qt::WindowStaysOnTopHint);
this->show(); // 确保窗口显示
return true;
}
} else if (mouseEvent->type() == QEvent::MouseButtonRelease) {
m_mousePressed = false;
return true;
} else if (mouseEvent->type() == QEvent::MouseMove) {
if (m_mousePressed && (mouseEvent->buttons() & Qt::LeftButton)) {
this->move(mouseEvent->globalPos() - m_mousePoint);
// 每次移动时设置为最上方
this->setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint | Qt::Window | Qt::WindowStaysOnTopHint);
this->show();
return true;
}
}
}
}
void MainWindow::addBeltWarnInfoToTextEdit(const QString& consoleInfo)
{
m_textEditConsoleInfo.append(consoleInfo);
QDateTime startDateTime = QDateTime::currentDateTime();
QString formattedTime = startDateTime.toString("yyyy-MM-dd hh:mm:ss");
@ -38,14 +77,12 @@ void MainWindow::addBeltWarnInfoToTextEdit(const QString &consoleInfo) {
return;
QString lastConsoleInfo = m_textEditConsoleInfo.last();
qint64 timeDifferenceInMilliseconds =
m_previousConsleInfoDateTime.secsTo(startDateTime);
qint64 timeDifferenceInMilliseconds = m_previousConsleInfoDateTime.secsTo(startDateTime);
if ((lastConsoleInfo == consoleInfo) && timeDifferenceInMilliseconds < 2)
return;
QString consoleInfoResult =
QStringLiteral("[%1]%2").arg(formattedTime).arg(consoleInfo);
QString consoleInfoResult = QStringLiteral("[%1]%2").arg(formattedTime).arg(consoleInfo);
ui->textEdit_beltWarnInfo->append(consoleInfoResult);
m_previousConsleInfoDateTime = QDateTime::currentDateTime();
@ -53,7 +90,8 @@ void MainWindow::addBeltWarnInfoToTextEdit(const QString &consoleInfo) {
void MainWindow::on_pushButton_close_clicked() { this->close(); }
void MainWindow::on_pushButton_max_clicked() {
void MainWindow::on_pushButton_max_clicked()
{
if (isFullScreen()) {
this->showMaximized();
} else {
@ -63,7 +101,8 @@ void MainWindow::on_pushButton_max_clicked() {
void MainWindow::on_pushButton_min_clicked() { this->showMinimized(); }
void MainWindow::calendarLoopPlay() {
void MainWindow::calendarLoopPlay()
{
ui->label_calendar->clear();
QTimer* timer_calendar = new QTimer(this);
connect(timer_calendar, &QTimer::timeout, this, [this]() {
@ -74,18 +113,28 @@ void MainWindow::calendarLoopPlay() {
timer_calendar->start(1000); //每一秒溢出一次进入槽函数
}
void MainWindow::setBeltWarnInfoTextEditStyle() {
void MainWindow::setSystemTitle()
{
QString titleName = m_systemSetting->value("system/name").toString();
if (!titleName.isEmpty()) {
ui->label_title->clear();
ui->label_title->setText(titleName);
}
}
void MainWindow::setBeltWarnInfoTextEditStyle()
{
ui->textEdit_beltWarnInfo->document()->setMaximumBlockCount(100);
ui->textEdit_beltWarnInfo->setReadOnly(true);
ui->textEdit_beltWarnInfo->setTextInteractionFlags(Qt::NoTextInteraction);
}
void MainWindow::addcoalDistributChart() {
void MainWindow::addcoalDistributChart()
{
// addBeltWarnInfoToTextEdit("添加煤流分布窗口成功!");
ui->textEdit_beltWarnInfo->append("添加煤流分布窗口成功!");
CoalDistributBarChartWidget *coalDistributBarChartWidget =
new CoalDistributBarChartWidget(this);
CoalDistributBarChartWidget* coalDistributBarChartWidget = new CoalDistributBarChartWidget(this);
// 检查布局是否已设置
if (!ui->widget_coalDistributChart->layout()) {
@ -96,7 +145,8 @@ void MainWindow::addcoalDistributChart() {
coalDistributBarChartWidget);
}
void MainWindow::addbeltSpeedChat() {
void MainWindow::addbeltSpeedChat()
{
ui->textEdit_beltWarnInfo->append("添加皮带机速度曲线窗口成功!");
BeltSpeedLineWidget* beltSpeedLineWidget = new BeltSpeedLineWidget(this);
// 检查布局是否已设置
@ -107,10 +157,10 @@ void MainWindow::addbeltSpeedChat() {
ui->widget_beltSpeedChart->layout()->addWidget(beltSpeedLineWidget);
}
void MainWindow::addCoalStatisticsChart() {
void MainWindow::addCoalStatisticsChart()
{
ui->textEdit_beltWarnInfo->append("添加煤量统计窗口成功!");
CoalStatisticsChartWidget *coalStatisticsChartWidget =
new CoalStatisticsChartWidget(this);
CoalStatisticsChartWidget* coalStatisticsChartWidget = new CoalStatisticsChartWidget(this);
// 检查布局是否已设置
if (!ui->widget_beltSpeedChart->layout()) {
ui->widget_beltSpeedChart->setLayout(new QVBoxLayout);
@ -120,9 +170,12 @@ void MainWindow::addCoalStatisticsChart() {
coalStatisticsChartWidget);
}
void MainWindow::addCoalBeltVideo() {
QString url = "https://stream7.iqilu.com/10339/upload_transcode/202002/18/"
"20200218114723HDu3hhxqIT.mp4";
void MainWindow::addCoalBeltVideo()
{
// QString url = "https://stream7.iqilu.com/10339/upload_transcode/202002/18/"
// "20200218114723HDu3hhxqIT.mp4";
// QString url = "rtsp://admin:1234qwer@192.168.80.82:554/Streaming/Channels/101";
QString url = m_systemSetting->value("camera/rtsp").toString();
ui->widget_beltVideo->setUrl(url);
ui->widget_beltVideo->open();
}

View File

@ -3,6 +3,7 @@
#include <QDateTime>
#include <QMainWindow>
#include <QSettings>
namespace Ui {
class MainWindow;
@ -15,6 +16,9 @@ public:
explicit MainWindow(QWidget* parent = nullptr);
~MainWindow();
protected:
bool eventFilter(QObject* watched, QEvent* event) override;
public slots:
/**
* @brief
@ -35,6 +39,11 @@ private:
*/
void calendarLoopPlay();
/**
* @brief setSystemTitle
*/
void setSystemTitle();
/**
* @brief setBeltWarnInfoTextEditStyle
*/
@ -72,6 +81,15 @@ private:
* @brief m_previousConsleInfoDateTime
*/
QDateTime m_previousConsleInfoDateTime;
/**
* @brief m_systemSetting
*/
QSettings* m_systemSetting;
// 窗口拖拽
QPoint m_mousePoint;
bool m_mousePressed { false };
};
#endif // MAINWINDOW_H

View File

@ -14,7 +14,7 @@
<string>MainWindow</string>
</property>
<property name="windowIcon">
<iconset resource="resource.qrc">
<iconset>
<normaloff>:/Resource/image/logo.png</normaloff>:/Resource/image/logo.png</iconset>
</property>
<widget class="QWidget" name="centralWidget">
@ -47,16 +47,15 @@
</property>
<property name="styleSheet">
<string notr="true">#widget_head{
border-image: url(:/Resource/image/title.png);
}</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="2,4,4,4,0">
<layout class="QHBoxLayout" name="horizontalLayout_2" stretch="2,3,4,3,0">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
<number>9</number>
</property>
<property name="rightMargin">
<number>0</number>
@ -77,6 +76,8 @@
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_56">
<item>
<widget class="QLabel" name="label_title">
<property name="styleSheet">
@ -90,6 +91,8 @@
</property>
</widget>
</item>
</layout>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
@ -103,6 +106,8 @@
</property>
</spacer>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_57">
<item>
<widget class="QLabel" name="label_calendar">
<property name="minimumSize">
@ -125,6 +130,8 @@
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_12">
<property name="spacing">
@ -3293,8 +3300,6 @@ QPushButton:pressed{
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="resource.qrc"/>
</resources>
<resources/>
<connections/>
</ui>

View File

@ -20,15 +20,20 @@
#include <memory>
CoalDistributBarChartWidget::CoalDistributBarChartWidget(QWidget* parent)
: QWidget(parent), m_tcpSocket(new QTcpSocket(this)) {
: QWidget(parent)
, m_tcpSocket(new QTcpSocket(this))
{
initializeChart();
m_systemSetting = new QSettings("system.ini", QSettings::IniFormat);
connectTCPSocket();
setupTimer();
}
CoalDistributBarChartWidget::~CoalDistributBarChartWidget() {
CoalDistributBarChartWidget::~CoalDistributBarChartWidget()
{
if (m_tcpSocket->state() == QAbstractSocket::ConnectedState) {
m_tcpSocket->disconnectFromHost();
m_tcpSocket->waitForDisconnected();
@ -36,21 +41,21 @@ CoalDistributBarChartWidget::~CoalDistributBarChartWidget() {
delete m_tcpSocket;
}
void CoalDistributBarChartWidget::updateChart() {
void CoalDistributBarChartWidget::updateChart()
{
int radio = getCoalRatioByTCPSocket();
// if (radio <= 0 || radio > 100) {
// return;
// }
if (radio <= 0 || radio > 100) {
return;
}
int setCount = m_set->count();
qDebug() << "setCount" << setCount;
m_set->remove(setCount - 1);
m_set->insert(0, radio);
}
void CoalDistributBarChartWidget::initializeChart() {
void CoalDistributBarChartWidget::initializeChart()
{
// 创建图标
m_chart = new QChart();
@ -110,7 +115,8 @@ void CoalDistributBarChartWidget::initializeChart() {
setLayout(layout);
}
void CoalDistributBarChartWidget::setupTimer() {
void CoalDistributBarChartWidget::setupTimer()
{
// 定时器设置
m_timer = new QTimer(this);
connect(m_timer, &QTimer::timeout, this,
@ -118,9 +124,10 @@ void CoalDistributBarChartWidget::setupTimer() {
m_timer->start(1000); // 每秒更新一次
}
void CoalDistributBarChartWidget::connectTCPSocket() {
QString ipAddress = "192.168.80.101"; // 替换为实际 IP 地址
quint16 port = 3000; // Modbus TCP 端口
void CoalDistributBarChartWidget::connectTCPSocket()
{
QString ipAddress = m_systemSetting->value("addr/ip").toString();
quint16 port = m_systemSetting->value("addr/port").toInt();
// 连接到 Modbus TCP 服务器
m_tcpSocket->connectToHost(ipAddress, port);
@ -129,7 +136,8 @@ void CoalDistributBarChartWidget::connectTCPSocket() {
}
}
int CoalDistributBarChartWidget::getCoalRatioByTCPSocket() {
int CoalDistributBarChartWidget::getCoalRatioByTCPSocket()
{
if (m_tcpSocket->state() != QAbstractSocket::ConnectedState) {
qDebug() << "未连接到服务器";
return -1; // 返回错误值
@ -175,8 +183,6 @@ int CoalDistributBarChartWidget::getCoalRatioByTCPSocket() {
return -1; // 返回错误值
}
qDebug() << "response" << response.toHex();
// 解析响应
QDataStream responseStream(response);
responseStream.setByteOrder(QDataStream::LittleEndian);
@ -208,12 +214,12 @@ int CoalDistributBarChartWidget::getCoalRatioByTCPSocket() {
bool isOk;
int decimalValue = lastFourBytes.toHex().toInt(&isOk, 16);
qDebug() << "最后四位:" << decimalValue;
return decimalValue; // 返回煤量占比
}
QByteArray CoalDistributBarChartWidget::createModbusTcpRequest() {
QByteArray CoalDistributBarChartWidget::createModbusTcpRequest()
{
QByteArray request;
QDataStream stream(&request, QIODevice::WriteOnly);
stream.setByteOrder(QDataStream::BigEndian); // 使用大端字节序

View File

@ -3,6 +3,7 @@
#include <QDateTime>
#include <QObject>
#include <QSettings>
#include <QTimer>
#include <QWidget>
@ -58,13 +59,9 @@ private:
QBarSet* m_set;
int currentIndex; // 当前更新的柱子的索引
static const int MaxDataPoints = 300; // 最大数据点数5分钟每秒1条
QList<QDateTime> m_timeLabels; // 存储时间标签
QTcpSocket* m_tcpSocket;
QSettings* m_systemSetting;
};
#endif // COALDISTRIBUTBARCHARTWIDGET_H

View File

@ -1,6 +1,7 @@
#include "coalstatisticschartwidget.h"
#include "ui_coalstatisticschartwidget.h"
#include <QHttpPart>
#include <QJsonDocument>
#include <QJsonObject>
#include <QNetworkAccessManager>
@ -15,6 +16,8 @@ CoalStatisticsChartWidget::CoalStatisticsChartWidget(QWidget* parent)
{
ui->setupUi(this);
m_systemSetting = new QSettings("system.ini", QSettings::IniFormat);
initCoalStatisticsBarChart();
getCoalStatisInfoByHttpRequest("2024-09-01 08", "2024-09-02 08");
@ -25,6 +28,104 @@ CoalStatisticsChartWidget::~CoalStatisticsChartWidget()
delete ui;
}
void CoalStatisticsChartWidget::on_pushButton_coalStatisOk_clicked()
{
// 时间范围
QString beginTimeStr = ui->dateTimeEdit_startTime->text();
QString endTimeStr = ui->dateTimeEdit_endTime->text();
qDebug() << "beginTimeStr" << beginTimeStr;
qDebug() << "endTimeStr" << endTimeStr;
// 创建 QDateTime 对象
QDateTime beginTime = QDateTime::fromString(beginTimeStr, "yyyy/MM/d HH:mm");
QDateTime endTime = QDateTime::fromString(endTimeStr, "yyyy/MM/d HH:mm");
// 判断是否转换成功
if (!beginTime.isValid() || !endTime.isValid()) {
qDebug() << "Invalid date/time format!";
return;
}
int unitIndex = ui->comboBox_unit->currentIndex();
// 选择的时间单位
switch (unitIndex) {
case TimeUnit::Hour: {
// 计算整时
QList<QDateTime> dateTimes;
int minutes = beginTime.time().minute(); // 获取分钟部分
beginTime = beginTime.addSecs(-minutes * 60); // 向下取整
// 遍历时间范围
while (beginTime <= endTime) {
dateTimes.append(beginTime);
beginTime = beginTime.addSecs(3600); // 增加1小时
}
// 输出结果
for (const QDateTime& dateTime : dateTimes) {
qDebug() << "整小时数" << dateTime.toString("yyyy/MM/d HH:mm");
}
break;
}
case TimeUnit::Day: {
// 计算整天
QList<QDateTime> dateTimes;
beginTime.setTime(QTime(0, 0)); // 将起始时间设置为当天的00:00:00
// 遍历时间范围
while (beginTime <= endTime) {
dateTimes.append(beginTime);
beginTime = beginTime.addDays(1); // 增加1天
}
// 输出结果
for (const QDateTime& dateTime : dateTimes) {
qDebug() << "整天数" << dateTime.toString("yyyy/MM/d");
}
break;
}
case TimeUnit::Month: {
// 计算整月
QList<QDateTime> dateTimes;
beginTime.setDate(QDate(beginTime.date().year(), beginTime.date().month(), 1)); // 设置为当月的1号
// 遍历时间范围
while (beginTime <= endTime) {
dateTimes.append(beginTime);
beginTime = beginTime.addMonths(1); // 增加1个月
}
// 输出结果
for (const QDateTime& dateTime : dateTimes) {
qDebug() << "整月数" << dateTime.toString("yyyy/MM");
}
break;
}
case TimeUnit::Year: {
// 计算整年
QList<QDateTime> dateTimes;
beginTime.setDate(QDate(beginTime.date().year(), 1, 1)); // 设置为当年的1月1日
// 遍历时间范围
while (beginTime <= endTime) {
dateTimes.append(beginTime);
beginTime = beginTime.addYears(1); // 增加1年
}
// 输出结果
for (const QDateTime& dateTime : dateTimes) {
qDebug() << "整年数" << dateTime.toString("yyyy");
}
break;
}
default:
qDebug() << "无效的时间单位!";
break;
}
}
void CoalStatisticsChartWidget::initCoalStatisticsBarChart()
{
// 创建图表
@ -45,29 +146,35 @@ void CoalStatisticsChartWidget::initCoalStatisticsBarChart()
m_chart->addSeries(m_series);
// 设置X轴为时间
QValueAxis* axisX = new QValueAxis;
axisX->setRange(1, 300);
axisX->setTickCount(10);
axisX->setLabelFormat("%d");
axisX->setLinePen(QPen(Qt::gray));
axisX->setLabelsColor(Qt::gray);
axisX->setMinorTickCount(0);
m_chart->addAxis(axisX, Qt::AlignBottom);
m_series->attachAxis(axisX);
m_axisX = new QDateTimeAxis;
m_axisX->setFormat("yyyy/MM/d H"); // 设置日期时间格式
// m_axisX->setTitleText("时间");
m_axisX->setTitleBrush(QBrush(Qt::gray));
m_axisX->setLinePen(QPen(Qt::gray));
m_axisX->setLabelsColor(Qt::gray);
// 获取当前时间并设置时间范围为最近六个小时
QDateTime currentTime = QDateTime::currentDateTime();
QDateTime startTime = currentTime.addSecs(-6 * 3600); // 当前时间减去六个小时
// m_axisX->setLabelsAngle(45);
// 设置X轴时间范围
m_axisX->setRange(startTime, currentTime);
m_chart->addAxis(m_axisX, Qt::AlignBottom);
m_series->attachAxis(m_axisX);
// 设置Y轴为百分比
QValueAxis* axisY = new QValueAxis;
axisY->setTitleText("");
axisY->setTitleBrush(QBrush(Qt::gray));
axisY->setLinePen(QPen(Qt::gray));
axisY->setLabelsColor(Qt::gray);
axisY->setRange(0, 100);
m_chart->addAxis(axisY, Qt::AlignLeft);
m_series->attachAxis(axisY);
// 设置Y轴标题位置
axisY->setTitleFont(QFont("Arial", 10));
axisY->setTitleVisible(true);
m_axisY = new QValueAxis;
m_axisY->setTitleText("");
m_axisY->setTitleBrush(QBrush(Qt::gray));
m_axisY->setLinePen(QPen(Qt::gray));
m_axisY->setLabelsColor(Qt::gray);
m_axisY->setRange(0, 100);
m_chart->addAxis(m_axisY, Qt::AlignLeft);
m_series->attachAxis(m_axisY);
m_axisY->setTitleFont(QFont("Arial", 10));
m_axisY->setTitleVisible(true);
// 获取 widget_coalChart 的布局
QVBoxLayout* layout = static_cast<QVBoxLayout*>(ui->widget_coalChart->layout());
@ -89,25 +196,37 @@ void CoalStatisticsChartWidget::initCoalStatisticsBarChart()
void CoalStatisticsChartWidget::getCoalStatisInfoByHttpRequest(const QString& beginTime, const QString& endTime)
{
QNetworkAccessManager* manager = new QNetworkAccessManager();
// 使用类成员变量 QNetworkAccessManager
QNetworkAccessManager* manager = new QNetworkAccessManager(this);
QString coalStaticUrl = m_systemSetting->value("coalStaticInterface/url").toString();
// URL
QUrl url("http://192.168.5.205:5002/api/get/coal/statistics/value/");
QUrl url(coalStaticUrl);
QNetworkRequest request(url);
// Form data
QUrlQuery params;
params.addQueryItem("begin_time", beginTime);
params.addQueryItem("end_time", endTime);
QHttpMultiPart* multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType);
// 设置请求头
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
// begin_time 参数
QHttpPart beginTimePart;
beginTimePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"begin_time\""));
beginTimePart.setBody(beginTime.toUtf8());
// end_time 参数
QHttpPart endTimePart;
endTimePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"end_time\""));
endTimePart.setBody(endTime.toUtf8());
// 将表单字段附加到 multipart 请求体中
multiPart->append(beginTimePart);
multiPart->append(endTimePart);
// 发送 POST 请求
QNetworkReply* reply = manager->post(request, params.query(QUrl::FullyEncoded).toUtf8());
QNetworkReply* reply = manager->post(request, multiPart);
// 连接信号和槽
QObject::connect(reply, &QNetworkReply::finished, [reply]() {
QObject::connect(reply, &QNetworkReply::finished, [this, reply, multiPart]() {
if (reply->error() == QNetworkReply::NoError) {
// 处理成功的响应
QByteArray responseData = reply->readAll();
@ -117,15 +236,19 @@ void CoalStatisticsChartWidget::getCoalStatisInfoByHttpRequest(const QString& be
int code = jsonObj["code"].toInt();
QString message = jsonObj["message"].toString();
QJsonObject data = jsonObj["data"].toObject();
double totalVolume = data["total_volume"].toDouble();
double totalVolume = data["total_volum"].toDouble();
qDebug() << "Code:" << code;
qDebug() << "Message:" << message;
qDebug() << "Total Volume:" << totalVolume;
} else {
// 处理错误
qDebug() << "Error:" << reply->errorString();
QString errorString = reply->errorString();
qDebug() << "Error:" << errorString;
}
// 清理资源
reply->deleteLater();
multiPart->deleteLater();
});
}

View File

@ -9,6 +9,13 @@ namespace Ui {
class CoalStatisticsChartWidget;
}
enum TimeUnit {
Hour = 0, // 时
Day = 1, // 天
Month = 2, // 月
Year = 3 // 年
};
class CoalStatisticsChartWidget : public QWidget {
Q_OBJECT
@ -16,6 +23,13 @@ public:
explicit CoalStatisticsChartWidget(QWidget* parent = nullptr);
~CoalStatisticsChartWidget();
private slots:
/**
* @brief on_pushButton_coalStatisOk_clicked
*/
void on_pushButton_coalStatisOk_clicked();
private:
/**
* @brief initCoalStatisticsBarChart
@ -33,7 +47,12 @@ private:
QChart* m_chart;
QChartView* m_chartView;
QBarSeries* m_series;
QDateTimeAxis* m_axisX;
QValueAxis* m_axisY;
QTimer* m_timer;
QSettings* m_systemSetting;
};
#endif // COALSTATISTICSCHARTWIDGET_H

View File

@ -32,13 +32,13 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>15</number>
<number>5</number>
</property>
<property name="leftMargin">
<number>10</number>
<number>6</number>
</property>
<property name="rightMargin">
<number>10</number>
<number>6</number>
</property>
<item>
<widget class="QLabel" name="label">
@ -204,6 +204,42 @@ QDateTimeEdit::up-button, QDateTimeEdit::down-button {
</item>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_coalStatisOk">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>45</width>
<height>20</height>
</size>
</property>
<property name="styleSheet">
<string notr="true">QPushButton{
border-image: url(:/Resource/image/labelunSelect.png);
color:white;
font-size: 14px;
border: none;
}
QPushButton:hover{
border-image: url(:/Resource/image/labelhover.png);
}
QPushButton:pressed{
border-image: url(:/Resource/image/labelSelect.png);
}
</string>
</property>
<property name="text">
<string>确定</string>
</property>
</widget>
</item>
</layout>
</item>
<item>