QSqlDatabase db;
db = QSqlDatabase::addDatabase("QPSQL"); db.setHostName("localhost"); db.setDatabaseName("test");
db.close(); if (role) { db.setUserName(...); db.setPassword(...); } else { db.setUserName(...); db.setPassword(...); } if (db.open()) { qDebug() << "NORM CONNECT" << db.userName(); } else { qCritical() << db.lastError(); }
QSqlDatabasePrivate::removeDatabase: connection 'qt_sql_default_connection' is still in use, all queries will cease to work.
Connect::~Connect(){ db.close(); db.removeDatabase("QPSQL");}
Autorization * atr = new Autorization(); Connect * first_connect = new Connect();
return a.exec(); delete first_connect; first_connect = NULL;
C++ (Qt)int res = a.exec();delete first_connect;return res;