hi,
I wish to Display two Dialogs(one object initializes another object).
so i have created MM, SM classes.
MM is the main object.
i want to show SM, in MM's initialization.
so i declared the SM object in MM'S constructor.
But when running the program , Only the MM Dialog is Visible.
SM Dialog is not visible.

as per the functional flow, main() will create MM, and MM will show.
then MM will create SM. and SM has to show.
But im getting the err here.

pls let me know, where my code went wrong.

How to show the second dialog in first dialog's constructor?

Below are the complete code.

main.cpp

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

mm.h
Qt Code:
  1. #ifndef MM_H
  2. #define MM_H
  3. #include <QDialog>
  4. #include <QtGui>
  5.  
  6. class mm : public QDialog
  7. {
  8. Q_OBJECT
  9. public:
  10. mm(QWidget *parent = 0);
  11. public slots:
  12. void showMM();
  13. };
  14. #endif // MM_H
To copy to clipboard, switch view to plain text mode 


mm.cpp
Qt Code:
  1. #include <QDialog>
  2. #include <QLayout>
  3. #include <QPushButton>
  4.  
  5. #include "mm.h"
  6. #include "sm.h"
  7.  
  8. mm::mm(QWidget *parent)
  9. : QDialog(parent)
  10. {
  11. QHBoxLayout *layout=new QHBoxLayout;
  12. QPushButton *p = new QPushButton("MM");
  13. connect(p,SIGNAL(clicked()),this,SLOT(showMM()));
  14. layout->addWidget(p);
  15. setLayout(layout);
  16. setWindowTitle("MainMenu");
  17. show();
  18.  
  19. sm s;
  20. }
  21.  
  22.  
  23. void mm::showMM()
  24. {
  25. QMessageBox::about(0,"","MM");
  26. }
To copy to clipboard, switch view to plain text mode 

sm.h
Qt Code:
  1. #ifndef SM_H
  2. #define SM_H
  3.  
  4. #include <QDialog>
  5. #include <QtGui>
  6.  
  7. class sm : public QDialog
  8. {
  9. Q_OBJECT
  10. public:
  11. sm(QWidget *parent = 0);
  12. public slots:
  13. void showSM();
  14. };
  15. #endif // SM_H
To copy to clipboard, switch view to plain text mode 

sm.cpp

Qt Code:
  1. #include "sm.h"
  2.  
  3. sm::sm(QWidget *parent)
  4. : QDialog(parent)
  5. {
  6. QHBoxLayout *layout1=new QHBoxLayout;
  7. QPushButton *p1 = new QPushButton("SM");
  8. layout1->addWidget(p1);
  9. setLayout(layout1);
  10. setWindowTitle("sub");
  11. this->show();
  12. }
  13.  
  14. void sm::showSM()
  15. {
  16. QMessageBox::about(0,"","SM");
  17. }
To copy to clipboard, switch view to plain text mode 

thanks
Bala