-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
41 lines (37 loc) · 839 Bytes
/
main.cpp
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
#include <QApplication>
#include <QTextCodec>
#include <QDebug>
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlDriverCreator>
#include <QtPlugin>
#include "mainwindow.h"
#include "login.h"
bool createConnections()
{
QSqlDatabase DB = QSqlDatabase::addDatabase("QMYSQL");
DB.setDatabaseName("Library");
DB.setUserName("root");
DB.setPassword("");
DB.setHostName("localhost");
DB.setPort(3306);
if(!DB.open()){
qDebug()<<DB.lastError().databaseText()<<"\n";
return false;
}
return TRUE;
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTextCodec::setCodecForTr(QTextCodec::codecForLocale());
if(!createConnections()){
return 1;
}
else{
qDebug()<<"ss"<<"\n";
}
login lg;
lg.show();
return a.exec();
}