// Erpel.cpp
#include "Erpel.h"
{
setupUi(this);
stackedWidget -> setCurrentIndex(0);
connect( actionHome,SIGNAL (triggered()), this, SLOT(slotHome()) );
connect( actionBackup,SIGNAL (triggered()), this, SLOT(fileBackup()) );
connect( actionRestore,SIGNAL (triggered()), this, SLOT(fileRestore()) );
// more code follows here ....
}
bool Erpel
::dbConnect(QString dbName
) {
QString iniFile
= curDir
+"/erpel.ini";
// get some parameters from erpel.ini
QString dbdriver
= settings.
value("database/dbdriver").
toString();
QString dbhost
= settings.
value("database/dbhost").
toString();
QString dbname
= settings.
value("database/dbname").
toString();
QString dbuser
= settings.
value("database/dbuser").
toString();
QString dbpasswd
= settings.
value("database/dbpasswd").
toString();
db.setHostName(dbhost);
db.setDatabaseName(dbName);
db.setUserName(dbuser);
db.setPassword(dbpasswd);
bool connect2Db = db.open(); // try to open the database ...
if (!connect2Db)
{
qApp->trUtf8("I was not able to connect to your database!"),
return false;
}
qDebug() << "dbconnect" << db.isValid();
return true;
}