-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
48 lines (45 loc) · 1.4 KB
/
main.cpp
File metadata and controls
48 lines (45 loc) · 1.4 KB
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
#include <QApplication>
#include <QMessageBox>
#include <QtSql>
#include "bibconv.h"
bool dbconnect()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("SloZh.sqlite");
//bool database_exists = ( QFile::exists("SloZh.sqlite") );
if (!db.open())
{
QMessageBox mb;
mb.setText("spData Error"
"Could not connect to the database spData.sqlite!\n\n"
"Following Errors:\n"
+ db.lastError().databaseText() + "\n"
+ db.lastError().driverText() +"\n"
+ db.databaseName()
+ "\n\nThis is a Fatal Error. Please make sure that all QtSql libraries are inlcuded."
"\nThe program will terminate");
mb.setWindowTitle("Database Connection Error");
mb.setIcon(QMessageBox::Critical);
mb.exec();
return false;
}
else
return true;
}
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
BibConv w;
w.show();
// Try to connect to database
// if( !dbconnect() )
// {
// QMessageBox mb;
// mb.setText("Failed to connect to database 'spData.sqlite'");
// mb.setWindowTitle("Database File Error");
// mb.setIcon(QMessageBox::Critical);
// mb.exec();
// return 1;
// }
return a.exec();
}