void readconstants::openDB(const int &Type){ QSqlDatabase db;switch (Type){case 0: db = QSqlDatabase::addDatabase("QSQLITE","myConstConnect"); break;case 1: db = QSqlDatabase::addDatabase("QSQLITE","myRoomConnect"); break;case 2:......
void writedb::writePanelsState(const QString &fileName,const QByteArray &geo_data,const QByteArray &layout_data){QSqlDatabase db = QSqlDatabase::database("mySettingsConnect",false);db.setDatabaseName(fileName);if (!db.open()) { QMessageBox::warning(0, QString::fromUtf8("Ошибка"), QString::fromUtf8("Ошибка при подключении к базе данных %1.").arg(fileName)); return; }db.transaction();QSqlQuery query(db);query.exec("DELETE FROM PanelsData;");query.prepare("INSERT INTO PanelsData (LayoutData, GeoData) " "VALUES (:layout, :geo)"); query.bindValue(":layout", layout_data); query.bindValue(":geo", geo_data); if (!query.exec()) QMessageBox::warning(0, QString::fromUtf8("Ошибка"), QString::fromUtf8("Не смогли записать информацию о панелях."));db.commit();//if (db.isOpen()) db.close(); memory leak - закрываю с помощью RemoveDB}
void readconstants::closeDB(const int &Type){switch (Type){case 0: QSqlDatabase::removeDatabase("myConstConnect"); break;case 1: QSqlDatabase::removeDatabase("myRoomConnect"); break;case 2: QSqlDatabase::removeDatabase("mySettingsConnect"); break;case 3: QSqlDatabase::removeDatabase("myBaseMaterialConnect"); break;