From 55ee2ea3b79bda43d53ee87fb4b2076040ac7659 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB?= Date: Thu, 10 Dec 2020 02:25:37 +0300 Subject: [PATCH] 3 --- Manager_DB_/main.cpp | 4 +- Manager_DB_/mainwindow.cpp | 26 +++++++++ Manager_DB_/mainwindow.h | 16 ++++++ Manager_DB_/mainwindow.ui | 112 ++++++++++++++++++------------------- 4 files changed, 98 insertions(+), 60 deletions(-) diff --git a/Manager_DB_/main.cpp b/Manager_DB_/main.cpp index 84235be..8a3a431 100644 --- a/Manager_DB_/main.cpp +++ b/Manager_DB_/main.cpp @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) std::string str; - std::cout << "Enter the command: " << std::endl; + /*std::cout << "Enter the command: " << std::endl; std::cout.flush(); std::getline(std::cin, str); QString command(str.c_str()); @@ -95,7 +95,7 @@ int main(int argc, char *argv[]) } while (str != "STOP PROGRAMM"); - return a.exec(); + return a.exec();*/ MainWindow w; w.show(); diff --git a/Manager_DB_/mainwindow.cpp b/Manager_DB_/mainwindow.cpp index 41a26bd..e7cefb6 100644 --- a/Manager_DB_/mainwindow.cpp +++ b/Manager_DB_/mainwindow.cpp @@ -6,6 +6,32 @@ MainWindow::MainWindow(QWidget *parent) , ui(new Ui::MainWindow) { ui->setupUi(this); + ui->lineEdit->setPlaceholderText("Enter the command"); + connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(ok_clicked())); + connect(ui->pushButton_2, SIGNAL(clicked()), this, SLOT(clear_clicked())); + connect(ui->actionExit, SIGNAL(clicked()), this, SLOT(exit_clicked())); +} + +void MainWindow::ok_clicked() { + QString command = ui->lineEdit->text(); + + QSqlQuery query; + bool cmd = query.exec(command); + + ui->textEdit_log->append(command); + ui->textEdit_log->append("\n"); + + if (!cmd) { + ui->textEdit_log->append(query.lastError().text()); + } +} + +void MainWindow::exit_clicked() { + QApplication::quit(); +} + +void MainWindow::clear_clicked() { + ui->lineEdit->clear(); } MainWindow::~MainWindow() diff --git a/Manager_DB_/mainwindow.h b/Manager_DB_/mainwindow.h index 4643e32..e3948d1 100644 --- a/Manager_DB_/mainwindow.h +++ b/Manager_DB_/mainwindow.h @@ -2,6 +2,17 @@ #define MAINWINDOW_H #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } @@ -17,5 +28,10 @@ public: private: Ui::MainWindow *ui; + +public slots: + void ok_clicked(); + void clear_clicked(); + void exit_clicked(); }; #endif // MAINWINDOW_H diff --git a/Manager_DB_/mainwindow.ui b/Manager_DB_/mainwindow.ui index eadbfef..9ef2b3d 100644 --- a/Manager_DB_/mainwindow.ui +++ b/Manager_DB_/mainwindow.ui @@ -26,53 +26,23 @@ MainWindow - - - - 0 - 20 - 150 - 431 - - - - - 150 - 0 - 621 - 451 + 220 + 10 + 541 + 311 - + 10 - 0 - 131 - 21 - - - - - Nirmala UI - 10 - - - - Список таблиц - - - - - - 0 - 530 - 691 - 31 + 330 + 751 + 191 @@ -80,46 +50,41 @@ <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } </style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&gt;&gt;&gt;</p> <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> - + - -10 - 450 - 781 - 81 + 593 + 531 + 80 + 31 - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:7.8pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html> + + OK - + - 730 - 530 - 41 + 11 + 531 + 571 31 - OK + - 690 - 530 - 41 + 680 + 531 + 80 31 @@ -127,6 +92,37 @@ p, li { white-space: pre-wrap; } clear + + + + 10 + 11 + 201 + 311 + + + + + + + + Nirmala UI + 10 + + + + <html><head/><body><p align="center"><span style=" font-size:12pt; font-weight:600;">Список таблиц</span></p></body></html> + + + Qt::RichText + + + + + + + + -- GitLab