I tried to pick the important ones:
main.cpp:
#include <QtGui/QApplication>
#include <QObject>
#include <QDebug>
#include "dialog.h"
#include "mainwindow.h"
#include "datenbank.h"
int main(int argc, char *argv[])
{
qDebug()<<"["<<(Datenbank::iMethodenZaehler++)<<"]"<<"enter main";
Dialog *d = new Dialog;
MainWindow *w = new MainWindow;
if(d->exec()){
w->show();
}else{
delete w;
delete d;
return 1;
}
delete d;
int i = a.exec();
qDebug()<<"["<<(--Datenbank::iMethodenZaehler)<<"]"<<"exit main";
return i;
}
#include <QtGui/QApplication>
#include <QObject>
#include <QDebug>
#include "dialog.h"
#include "mainwindow.h"
#include "datenbank.h"
int main(int argc, char *argv[])
{
qDebug()<<"["<<(Datenbank::iMethodenZaehler++)<<"]"<<"enter main";
QApplication a(argc, argv);
Dialog *d = new Dialog;
MainWindow *w = new MainWindow;
QObject::connect(d,SIGNAL(signalUser(QString)),w,SLOT(slotUser(QString)));
if(d->exec()){
w->show();
}else{
delete w;
delete d;
return 1;
}
delete d;
int i = a.exec();
qDebug()<<"["<<(--Datenbank::iMethodenZaehler)<<"]"<<"exit main";
return i;
}
To copy to clipboard, switch view to plain text mode
datenbank.cpp:
(every method in the datenbank class is static)
#include "datenbank.h"
myDB.setDatabaseName(qsDB);
myDB.setHostName(qsHost);
myDB.setUserName(qsNutzer);
myDB.setPassword(qsKW);
myDB.setPort(iPort);
qDebug()<<myDB.drivers();
bool b = false;
checkOpenConnection(mode);
if(myDB.isOpen()){
b=true;
checkCloseConnection(mode);
}else{
qDebug()<<myDB.lastError();
}
return b;
}
#include "datenbank.h"
QSqlDatabase Datenbank::myDB = QSqlDatabase::addDatabase("QMYSQL");
bool Datenbank::initDB(QString qsDB,QString qsHost,QString qsNutzer, QString qsKW, int iPort, DB_MODES mode){
myDB.setDatabaseName(qsDB);
myDB.setHostName(qsHost);
myDB.setUserName(qsNutzer);
myDB.setPassword(qsKW);
myDB.setPort(iPort);
qDebug()<<myDB.drivers();
bool b = false;
checkOpenConnection(mode);
if(myDB.isOpen()){
b=true;
checkCloseConnection(mode);
}else{
qDebug()<<myDB.lastError();
}
return b;
}
To copy to clipboard, switch view to plain text mode
includes in datenbank.h:
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
#include <QStringList>
#include <QVariant>
#include <QDebug>
#include <QDateTime>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
#include <QStringList>
#include <QVariant>
#include <QDebug>
#include <QDateTime>
To copy to clipboard, switch view to plain text mode
Hope this helps.
Bookmarks