how do you hide the main Window after opening the second Window?Also, when the second Window is closed by the user, how can the main window reappear?

these are the codes I have so far.
I have an error that says ERROR:no matching constructor for initialization 'Dialog'...it's at the mainwindow.cpp ...this is the only error I have. Please help me fix it.

.H FILES

mainwidow.h
Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include <QMainWindow>
  5.  
  6. namespace Ui {
  7. class MainWindow;
  8. }
  9.  
  10. class MainWindow : public QMainWindow
  11. {
  12. Q_OBJECT
  13.  
  14. public:
  15. explicit MainWindow(QWidget *parent = nullptr);
  16. ~MainWindow();
  17.  
  18. public:
  19. void show();
  20.  
  21.  
  22.  
  23. private slots:
  24. void on_pushButton_clicked();
  25.  
  26. private:
  27. Ui::MainWindow *ui;
  28. };
  29.  
  30. #endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode 



secwindow.h

Qt Code:
  1. #ifndef SECWINDOW_H
  2. #define SECWINDOW_H
  3.  
  4. #include <QDialog>
  5.  
  6. namespace Ui {
  7. class SecWindow;
  8. }
  9.  
  10. class SecWindow : public QDialog
  11. {
  12. Q_OBJECT
  13.  
  14. public:
  15. explicit SecWindow(QWidget *parent = nullptr);
  16. ~SecWindow();
  17.  
  18.  
  19. private:
  20. Ui::SecWindow *ui;
  21. };
  22.  
  23. class Dialog : public QDialog
  24. {
  25. public:
  26. Dialog();
  27.  
  28. private:
  29. Dialog *dialog;
  30.  
  31. };
  32.  
  33.  
  34. #endif // SECWINDOW_H
To copy to clipboard, switch view to plain text mode 


SOURCE CODE

main.cpp

Qt Code:
  1. #include "mainwindow.h"
  2. #include <QApplication>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. QApplication a(argc, argv);
  7. a.setQuitOnLastWindowClosed(false);
  8. MainWindow w;
  9. w.show();
  10.  
  11. return a.exec();
  12. }
To copy to clipboard, switch view to plain text mode 

mainwindow.cpp

Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3. #include <QMessageBox>
  4. #include <QPixmap>
  5. #include "secwindow.h"
  6. #include <QDialog>
  7.  
  8. MainWindow::MainWindow(QWidget *parent) :
  9. QMainWindow(parent),
  10. ui(new Ui::MainWindow)
  11. {
  12. ui->setupUi(this);
  13. QPixmap pix("C:/Users/Charlene/Downloads/Charlene Back-up/MAPUA/2nd Term/Object Oriented Programming/GOW-Gui/GOW-GUI/intro pic/intro.png");
  14. ui->label->setPixmap(pix.scaled(230,250,Qt::KeepAspectRatio));
  15.  
  16. // QWidget *wdg = new QWidget;
  17. //wdg->show();
  18. //hide();
  19. }
  20.  
  21. MainWindow::~MainWindow()
  22. {
  23. delete ui;
  24. }
  25.  
  26. void MainWindow::on_pushButton_clicked() // Modal approach..mainwindow cannot be moved when secwindow is displayed.
  27. {
  28. SecWindow secwindow;
  29. secwindow.setModal(true); //it'll set the secwindow
  30. secwindow.exec(); //shows secwindow when button is pressed
  31. }
  32.  
  33. void MainWindow::show()
  34. {
  35. Dialog *dialog = new Dialog(this); //ERROR: no matching constructor for initialization of 'Dialog'
  36. connect(dialog, SIGNAL(accepted()), this, SLOT(show()));
  37. connect(dialog, SIGNAL(rejected()), this, SLOT(show()));
  38. dialog->show();
  39. hide();
  40. };
To copy to clipboard, switch view to plain text mode 



secwindow.cpp

Qt Code:
  1. #include "secwindow.h"
  2. #include "ui_secwindow.h"
  3. #include <QPixmap>
  4.  
  5. SecWindow::SecWindow(QWidget *parent) :
  6. QDialog(parent),
  7. ui(new Ui::SecWindow)
  8. {
  9. ui->setupUi(this);
  10. QPixmap pix("C:/Users/Charlene/Downloads/Charlene Back-up/MAPUA/2nd Term/Object Oriented Programming/GOW-Gui/GOW-GUI/images/102.gif");
  11. ui->label_2 ->setPixmap(pix.scaled(100,95, Qt::KeepAspectRatio));
  12. }
  13.  
  14. SecWindow::~SecWindow()
  15. {
  16. delete ui;
  17. }
To copy to clipboard, switch view to plain text mode