aboutsummaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/mainwindow.cpp20
-rw-r--r--client/mainwindow.h7
-rw-r--r--client/mainwindow.ui4
3 files changed, 25 insertions, 6 deletions
diff --git a/client/mainwindow.cpp b/client/mainwindow.cpp
index 955307e..80a7658 100644
--- a/client/mainwindow.cpp
+++ b/client/mainwindow.cpp
@@ -32,11 +32,25 @@ void MainWindow::on_pushButton_clicked()
// dbRef.setPassword("Ab12345!");
// dbRef.setDatabaseName("thecrapbox");
+ series = new QLineSeries();
+ QChart *chart = new QChart();
+
if(dbRef.open()){
QMessageBox::information(this, "Connection", "GREAT SUCCES!");
- pQueryModel = new QSqlQueryModel();
- pQueryModel->setQuery("SELECT * FROM opleiding;");
- ui->tableView->setModel(pQueryModel);
+ QSqlQuery queryGraphData;
+ queryGraphData.exec("SELECT id, temp FROM tblMain LIMIT 16 ORDER BY desc;");
+// ui->tableView->setModel(pQueryModel);
+ for (int i = 0; queryGraphData.next(); ++i) {
+ series->append(queryGraphData.value(0).toInt(), queryGraphData.value(1).toInt());
+ }
+ chart->legend()->show();
+ chart->addSeries(series);
+ chart->createDefaultAxes();
+ chart->setTitle("Hellow!");
+ chartView = new QChartView(chart);
+
+ MainWindow::setCentralWidget(chartView);
+
} else {
QMessageBox::warning(this, "No connection", "Failed to connect");
}
diff --git a/client/mainwindow.h b/client/mainwindow.h
index 1e73657..78f2ce6 100644
--- a/client/mainwindow.h
+++ b/client/mainwindow.h
@@ -8,6 +8,10 @@
#include <QMessageBox>
#include <QtSql>
#include <QSqlDatabase>
+#include <QtCharts>
+#include <QWidget>
+#include <QWidgetSet>
+
#include "main.h"
@@ -36,7 +40,8 @@ private:
dbConnector *_dbConenctor;
// QSqlDatabase db;
- QSqlQueryModel *pQueryModel;
+ QLineSeries *series;
+ QChartView *chartView;
// Database database;
};
diff --git a/client/mainwindow.ui b/client/mainwindow.ui
index f827c85..e55caa0 100644
--- a/client/mainwindow.ui
+++ b/client/mainwindow.ui
@@ -41,7 +41,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
- <widget class="QTableView" name="tableView"/>
+ <widget class="QWidget" name="widget" native="true"/>
</item>
</layout>
</widget>
@@ -52,7 +52,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
- <height>21</height>
+ <height>24</height>
</rect>
</property>
<widget class="QMenu" name="menuAbouy">