I am implementing an experimental registration program, and I made a case where, if a person does not type and tries to register this empty data, it opens QDialog
, receives the warning and does not complete the registration. Basically the code is:
MainWindow class:
#include "dado.h"
#include "dialog.h"
class MainWindow : public QMainWindow
{
[...]
private slots:
void on_botaoInserir_clicked();
private:
Ui::MainWindow *ui;
Dado *dado;
Dialog dialog;
};
The class MainWindow
(main program window) has an object of type dialog
that is implemented by class Dialog
:
Dialog class:
#include <QDialog>
namespace Ui {
class Dialog;
}
class Dialog : public QDialog
{
Q_OBJECT
public:
explicit Dialog(QWidget *parent = 0);
~Dialog();
void setAviso(QString);
QString getAviso();
private slots:
void on_dialogButton_clicked();
private:
Ui::Dialog *ui;
};
How to make MainWindow
only clickable after the dialog window is closed? Because even with the open dialog window I can still move and perform another registration in the main window.
Excerpt that opens the dialog if the user does not enter the data and tries to register (located at MainWindow
):
[...]
ui->statusBar->showMessage("Pessoa adicionada.", SB_MESS_TIME);
}
else{
dialog.setAviso("Digite um nome.");
dialog.setFocus();
dialog.show();
}
[...]
I hope someone says a way to "lock" the main window while the dialog
object above is running the show()
function.