blob: 955307e59d305ffeff94dd6ffa3477ea73a44e06 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
#include <QSqlDatabase>
#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();
}
|