From ef2b2a072e2425650eebc7d4ec63992332272109 Mon Sep 17 00:00:00 2001 From: Andrey Kutin Date: Thu, 15 Oct 2026 19:00:22 +0300 Subject: [PATCH] add: added function onAuth --- auth.cpp | 12 ++++++++++++ auth.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/auth.cpp b/auth.cpp index 98ccadb..838c1fe 100644 --- a/auth.cpp +++ b/auth.cpp @@ -33,4 +33,16 @@ auth::auth (QWidget *parent) void auth::onAuth () { + QSqlDatabase *db = new QSqlDatabase(QSqlDatabase::addDatabase("QPSQL")); + db->setHostName(_addressEdit->text()); + db->setPort(_portEdit->text().toInt()); + db->setDatabaseName("cards"); + db->setUserName(_nicknameEdit->text()); + db->setPassword(_passwordEdit->text()); + bool ok = db->open(); + if (!ok) { + // Error to open db + close(); + } + emit dbOpenned(db); } diff --git a/auth.h b/auth.h index f33cf7a..0a21548 100644 --- a/auth.h +++ b/auth.h @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -28,6 +29,7 @@ private: public slots: void onAuth (); signals: + void dbOpenned(QSqlDatabase *); }; #endif // AUTH_H