Unsolved How To Close All Window
-
Hello guys, i want close all Qapp when, dialog (on push button clicked) is closed. Do you have any idea?
-
Hi! To quit, you can use
void QCoreApplication::quit() [static slot]
, see http://doc.qt.io/Qt-5/qcoreapplication.html#quit. -
@Wieland
Yes it will disconnect my dialogue when pressed, but I want to be shut down Mainwindow, because I use dialogue mainwindow. -
Sorry, I don't understand what you mean.
-
@Wieland
dialog.cpp#include "user_panel.h" #include "ui_user_panel.h" #include "dal.h" #include "QSql" #include "QSqlDatabase" #include "QDebug" #include "mainwindow.h" user_panel::user_panel(QWidget *parent) : QDialog(parent), ui(new Ui::user_panel) { ui->setupUi(this); this->setWindowFlags(Qt::CustomizeWindowHint); } user_panel::~user_panel() { delete ui; } void user_panel::on_login_clicked() { QString user ="" , pass =""; user = ui->username->text(); pass = ui->password->text(); DAL* connect_dal = new DAL(); QSqlQuery query; int count = 0; if(query.exec("SELECT * FROM users WHERE USERNAME='"+user+"' AND PASSWORD='"+pass+"'")){ while(query.next()){ count++; } if(!count){ ui->warning->setText("არასწორია მომხმარებლის პაროლი/პაროლი"); }else{ this->close(); } } } void user_panel::on_quitt_clicked() { //... }
mainwindow.cpp
#include "mainwindow.h" #include "ui_mainwindow.h" #include "QWidget" #include "namee.h" #include "QDebug" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); login_form = new user_panel(); login_form->setModal(true); login_form->exec(); login_form->close(); } MainWindow::~MainWindow() { delete ui; }
When quitt (quitt is button name) button, clicked my dialogue, I want to shut down the whole project.
sorry english :))[Edit: Added code tags -- @Wieland]
-
Oh, so you only want to show a modal dialog once? And when this is closed, you want your application to terminate?
-
@Wieland
Yes. I want to shut down all project, user_panel, mainwindow and anymore :D -
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); login_form = new user_panel(); login_form->setModal(true); login_form->exec(); login_form->close(); close(); // <--- close main window }
-
@Wieland
wtf: D: D: D
So, I have a two button on dialog:
one: log_in button, if the user was found.
two: quit button, When he was not entering the correct username/password, I want to shut down whole project. -
I still don't get it :)
Maybe you want to check the return value of QDialog::exec() ? See http://doc.qt.io/qt-5/qdialog.html#exec