-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbConnect.h
31 lines (26 loc) · 806 Bytes
/
dbConnect.h
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
#ifndef DBCONNECT_H
#define DBCONNECT_H
#include <QMessageBox>
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
#include <QtDebug>
#include <QSqlQueryModel>
#include <QTableView>
static bool createConnection()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("DynamicLocation.db");
if (!db.open())
{
QMessageBox::critical(0, "Cannot open database",
"Unable to establish a database connection.\n"
"This example needs SQLite support. Please read "
"the Qt SQL driver documentation for information how "
"to build it.\n\n"
"Click Cancel to exit.", QMessageBox::Cancel);
return false;
}
return true;
}
#endif // DBCONNECT_H