diff options
author | lonkaars <loek@pipeframe.xyz> | 2022-10-05 20:28:50 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2022-10-05 20:28:50 +0200 |
commit | a1ca8f1f4764b279456018690decd93135d4c699 (patch) | |
tree | 7992535ba262da1708ee2a51e17122180b709428 /Qt/mainwindow.cpp | |
parent | 6e63028aec15f93bf82a0452b45a6b4dfec81f05 (diff) | |
parent | 40e937f75dee1e612710730b6d281a21131cc159 (diff) |
Merge branch 'dev' of https://github.com/UnavailableDev/avans-whether-station-Qt into qt-dev
Diffstat (limited to 'Qt/mainwindow.cpp')
-rw-r--r-- | Qt/mainwindow.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/Qt/mainwindow.cpp b/Qt/mainwindow.cpp new file mode 100644 index 0000000..c475414 --- /dev/null +++ b/Qt/mainwindow.cpp @@ -0,0 +1,48 @@ +#include "mainwindow.h" +#include "./ui_mainwindow.h" +#include "main.h" + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) + , ui(new Ui::MainWindow) +{ +// db = QSqlDatabase::addDatabase("QMYSQL"); + ui->setupUi(this); +} + +MainWindow::~MainWindow() +{ + dbRef.close(); + delete ui; +} + +void MainWindow::on_actionAbout_triggered() +{ + QMessageBox::warning(this, "Oops..", "Task Failed succesfully ;)"); +} + + +void MainWindow::on_pushButton_clicked() +{ +// dbRef = QSqlDatabase::addDatabase("QMYSQL"); +// dbRef.setHostName("localhost"); +// dbRef.setUserName("root"); +// dbRef.setPassword("Ab12345!"); +// dbRef.setDatabaseName("thecrapbox"); + + if(dbRef.open()){ + QMessageBox::information(this, "Connection", "GREAT SUCCES!"); + pQueryModel = new QSqlQueryModel(); + pQueryModel->setQuery("SELECT * FROM opleiding;"); + ui->tableView->setModel(pQueryModel); + } else { + QMessageBox::warning(this, "No connection", "Failed to connect"); + } +} + +void MainWindow::on_actionConnection_triggered() +{ + _dbConenctor = new dbConnector(this); + _dbConenctor->show(); +} + |