Morea
29th January 2009, 22:54
I have a class, and now I wish to add database connections to the constructor for that class.
I have code like
for (int i=0;i<nr_of_connects;i++)
{
QString name("mydb_con");
name.append(QString(i));
X = QSqlDatabase::addDatabase("QMYSQL",name);
X.open();
}
The problem is the "X" part. What do I write there? Should I declare a QList<QSqlDatabase> in the class or QList<QSqlDatabase*> ?
I will not know how many database connections there will be at compile time :-(
I have code like
for (int i=0;i<nr_of_connects;i++)
{
QString name("mydb_con");
name.append(QString(i));
X = QSqlDatabase::addDatabase("QMYSQL",name);
X.open();
}
The problem is the "X" part. What do I write there? Should I declare a QList<QSqlDatabase> in the class or QList<QSqlDatabase*> ?
I will not know how many database connections there will be at compile time :-(