aboutsummaryrefslogtreecommitdiff
path: root/client/mainwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'client/mainwindow.cpp')
-rw-r--r--client/mainwindow.cpp75
1 files changed, 53 insertions, 22 deletions
diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp
index d8b12cb..cc19b53 100644
--- a/client/mainwindow.cpp
+++ b/client/mainwindow.cpp
@@ -37,49 +37,80 @@ void MainWindow::on_actionDisconnenct_triggered()
void MainWindow::drawGraph(){
-// QLineSeries *seriesTemperature;
-// seriesTemperature = new QLineSeries();
+ QLineSeries *seriesTemperature = new QLineSeries();
QLineSeries *seriesHumidity = new QLineSeries();
-// QLineSeries *seriesPressure = new QLineSeries();
+ 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 * FROM `tblMain`ORDER BY `tblMain`.`ID` DESC limit 16;");
+ queryGraphData.exec("select * FROM `tblMain` ORDER BY `tblMain`.`ID` ASC limit 16;");
for (int i = 0; queryGraphData.next(); ++i) {
-// seriesTemp->append(queryGraphData.value(0).toInt(), queryGraphData.value(1).toInt());
+// int time = queryGraphData.value(4).toTime().hour()*100 + queryGraphData.value(4).toTime().minute();
+ int time = i;
+// seriesPressure->append(queryGraphData.value(0).toInt(), queryGraphData.value(1).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();
+// seriesPressure->append(i, queryGraphData.value(3).toInt());
+
+ seriesTemperature->append(time, queryGraphData.value(1).toFloat());
+ seriesHumidity->append(time, queryGraphData.value(2).toFloat());
+ seriesPressure->append(time, (queryGraphData.value(3).toFloat()*100));
+
+// qDebug() << time;
}
- QPen pen(QRgb(0x57FF00));
- pen.setWidth(5);
- seriesHumidity->setPen(pen);
+// QPen pen(QRgb(0x57FF00));
+// pen.setWidth(5);
+// seriesHumidity->setPen(pen);
+
+
+ QChart *chartTemperature = new QChart();
+ chartTemperature->legend()->hide();
+ chartTemperature->addSeries(seriesTemperature);
+ chartTemperature->createDefaultAxes();
+ chartTemperature->setTitle("Temperature!");
+ QChartView *chartView1 = new QChartView(chartTemperature);
+
+ QChart *chartHumidity = new QChart();
+ chartHumidity->legend()->hide();
+ chartHumidity->addSeries(seriesHumidity);
+ chartHumidity->createDefaultAxes();
+ chartHumidity->setTitle("Humidity!");
+ QChartView *chartView2 = new QChartView(chartHumidity);
+ QChart *chartPressure = new QChart();
+ chartPressure->legend()->hide();
+ chartPressure->addSeries(seriesPressure);
+ chartPressure->createDefaultAxes();
+ chartPressure->setTitle("Pressure!");
+ QChartView *chartView3 = new QChartView(chartPressure);
- _pChart = new QChart();
- _pChart->legend()->show();
-// _pChart->addSeries(seriesTemperature);
- _pChart->addSeries(seriesHumidity);
-// _pChart->addSeries(seriesPressure);
- _pChart->createDefaultAxes();
- _pChart->setTitle("Weather data:");
- _pChartView = new QChartView(_pChart);
- MainWindow::setCentralWidget(_pChartView);
+ QWidget *window = new QWidget;
+ QGridLayout *layout = new QGridLayout(window);
+ layout->addWidget(chartView1, 0 ,0);
+ layout->addWidget(chartView2, 1 ,0);
+ layout->addWidget(chartView3, 2 ,0);
+ layout->setVerticalSpacing(0);
+ layout->setHorizontalSpacing(0);
+ layout->setContentsMargins(0,0,0,0);
+
+
+
+// window->show();
+
+ MainWindow::setCentralWidget(window);
} else {
QMessageBox::warning(this, "No connection", "Failed to connect");
}
// delete seriesTemperature;
- delete seriesHumidity;
+// delete seriesHumidity;
// delete seriesPressure;
}
-