From 40e937f75dee1e612710730b6d281a21131cc159 Mon Sep 17 00:00:00 2001 From: UnavailableDev Date: Wed, 5 Oct 2022 20:16:11 +0200 Subject: First merge Qt App --- Qt/mainwindow.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Qt/mainwindow.cpp (limited to 'Qt/mainwindow.cpp') 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(); +} + -- cgit v1.2.3