szisziszilvi
31st March 2011, 13:39
Hi,
my testprogram works fine, I just wonder why I keep having a warning message.
I created a new GUI project, and gave one single more header file, which was "stolen" from the chatchedtable exapmle, but I modified the contents of the createconnection file in order to make connection to my own database. So now it looks like this:
#ifndef CONNECTION_H
#define CONNECTION_H
#include <QtSql/QSqlDatabase>
static bool createConnection()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
db.setHostName("myhostname");
db.setPort(5432);
db.setDatabaseName("mydbname");
db.setUserName("myusn");
db.setPassword("mypwd");
if (!db.open()) return false;
else return true;
}
#endif // CONNECTION_H
I included this header to the mainwindow.h with the line
#include "createconnection.h"
and there's a simple QSqlTableModel output of a table of my database just to see if it works.
And that's all. Whenever I compile the project there is the warning message:
'bool createConnection()' defined but not used
and I get it twice as if it was detected twice.
It is pretty wierd as if it wasn't used, the connection shouldn't be estabilished, should it?
my testprogram works fine, I just wonder why I keep having a warning message.
I created a new GUI project, and gave one single more header file, which was "stolen" from the chatchedtable exapmle, but I modified the contents of the createconnection file in order to make connection to my own database. So now it looks like this:
#ifndef CONNECTION_H
#define CONNECTION_H
#include <QtSql/QSqlDatabase>
static bool createConnection()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");
db.setHostName("myhostname");
db.setPort(5432);
db.setDatabaseName("mydbname");
db.setUserName("myusn");
db.setPassword("mypwd");
if (!db.open()) return false;
else return true;
}
#endif // CONNECTION_H
I included this header to the mainwindow.h with the line
#include "createconnection.h"
and there's a simple QSqlTableModel output of a table of my database just to see if it works.
And that's all. Whenever I compile the project there is the warning message:
'bool createConnection()' defined but not used
and I get it twice as if it was detected twice.
It is pretty wierd as if it wasn't used, the connection shouldn't be estabilished, should it?