aboutsummaryrefslogtreecommitdiff
path: root/client/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'client/mainwindow.cpp')
-rw-r--r--client/mainwindow.cpp47
1 files changed, 33 insertions, 14 deletions
diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp
index d3da553..d8b12cb 100644
--- a/client/mainwindow.cpp
+++ b/client/mainwindow.cpp
@@ -4,7 +4,7 @@
#include "ui_mainwindow.h"
#include "main.h"
-//#include <QDebug>
+#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
@@ -25,30 +25,48 @@ void MainWindow::on_actionConnection_triggered()
_dbConenctor->show();
}
-
void MainWindow::on_actionRefresh_triggered()
{
- QLineSeries *seriesTemperature = new QLineSeries();
+ drawGraph();
+}
+
+void MainWindow::on_actionDisconnenct_triggered()
+{
+ dbRef.close();
+}
+
+
+void MainWindow::drawGraph(){
+// QLineSeries *seriesTemperature;
+// seriesTemperature = new QLineSeries();
QLineSeries *seriesHumidity = new QLineSeries();
- QLineSeries *seriesPressure = new QLineSeries();
- _pChart = new QChart();
+// QLineSeries *seriesPressure = new QLineSeries();
+
if(dbRef.open()){
QSqlQuery queryGraphData;
- queryGraphData.exec("select `tblMain`.`ID`, `temperature`, `humidity`, `pressure` FROM `tblMain` ORDER BY `tblMain`.`ID` DESC limit 16;");
-// queryGraphData.exec("select `tblMain`.`ID`, `temperature`, `humidity`, `pressure` FROM `tblMain`;");
+// queryGraphData.exec("select `tblMain`.`ID`, `temperature`, `humidity`, `pressure` FROM `tblMain` ORDER BY `tblMain`.`ID` DESC limit 16;");
+ queryGraphData.exec("select * FROM `tblMain`ORDER BY `tblMain`.`ID` DESC limit 16;");
for (int i = 0; queryGraphData.next(); ++i) {
// seriesTemp->append(queryGraphData.value(0).toInt(), queryGraphData.value(1).toInt());
- seriesTemperature->append(i, queryGraphData.value(1).toFloat());
- seriesHumidity->append(i, queryGraphData.value(2).toFloat()*100);
- seriesPressure->append(i, queryGraphData.value(3).toFloat());
+// seriesTemperature->append(i, queryGraphData.value(1).toInt());
+// seriesHumidity->append(i, queryGraphData.value(2).toFloat());
+ seriesHumidity->append(i,i);
+// seriesPressure->append(i, queryGraphData.value(3).toFloat());
+ qDebug() << queryGraphData.value(2).toFloat();
}
+ QPen pen(QRgb(0x57FF00));
+ pen.setWidth(5);
+ seriesHumidity->setPen(pen);
+
+
+ _pChart = new QChart();
_pChart->legend()->show();
- _pChart->addSeries(seriesTemperature);
+// _pChart->addSeries(seriesTemperature);
_pChart->addSeries(seriesHumidity);
- _pChart->addSeries(seriesPressure);
+// _pChart->addSeries(seriesPressure);
_pChart->createDefaultAxes();
_pChart->setTitle("Weather data:");
_pChartView = new QChartView(_pChart);
@@ -59,8 +77,9 @@ void MainWindow::on_actionRefresh_triggered()
} else {
QMessageBox::warning(this, "No connection", "Failed to connect");
}
- delete seriesTemperature;
+// delete seriesTemperature;
delete seriesHumidity;
- delete seriesPressure;
+// delete seriesPressure;
}
+