aboutsummaryrefslogtreecommitdiff
path: root/client/mainwindow.cpp
diff options
context:
space:
mode:
authorUnavailableDev <69792062+UnavailableDev@users.noreply.github.com>2022-10-13 11:03:30 +0200
committerUnavailableDev <69792062+UnavailableDev@users.noreply.github.com>2022-10-13 11:03:30 +0200
commit093f18ab363840fff796c14e6c7ad7b93dd0ffc6 (patch)
treed6a77d18b27c64547adcd866b175aeb621677116 /client/mainwindow.cpp
parent1032c63bae663d8ed8736020b60a4ba8744062ee (diff)
testing charts
Diffstat (limited to 'client/mainwindow.cpp')
-rw-r--r--client/mainwindow.cpp20
1 files changed, 17 insertions, 3 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");
}