I've created an app that contains a Widget . I've put all the ctrls I need into it .
I've created my own Slots by creating a (Header + cpp) files to implement the functionality I want .

Everything ,so far , goes fine .


Now I've created another Widget . when I try to display the 2nd widget it just appears for a second !!
-I've created 2 HeaderFiles +2 .CPP files ; I mean each widget has its .cpp + .h .


My Questions are :

1- I need when the user press a button @ the 1st widget
, the 2nd widget shows .

2- How Could I close a specific Widget ?!!
3 - Do I 've to create @ my app a "Main Window"
4- Finally , Do I 've to create a Header + .cpp file to each Widget I've ?!!

My Main function's Code :

Qt Code:
  1. #include <QApplication>
  2. #include <QDialog>
  3. #include"CustomSlot.cpp"
  4. #include "ui_Test.h"
  5.  
  6.  
  7.  
  8. int main(int argc, char *argv[])
  9. {
  10. QApplication app(argc, argv);
  11.  
  12. CustomSlot widget;
  13. widget.show();
  14. return app.exec();
  15. }
To copy to clipboard, switch view to plain text mode 

-------------------------------------------------------------------------------------------
First CustomSlot.cpp 's code :

Qt Code:
  1. #include"CustomSlot.h"
  2. #include "ui_Test.h"
  3.  
  4. #include "ui_Form2.h"
  5. #include"CustomSlot2.cpp"
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12. CustomSlot::CustomSlot(QWidget *parent): QWidget(parent)
  13. {
  14. ui.setupUi(this);
  15. }
  16.  
  17.  
  18. void CustomSlot:: OpenNxtWindow()
  19. {
  20.  
  21. CustomSlot2 widget;
  22. widget.show();
  23.  
  24. }
To copy to clipboard, switch view to plain text mode 
-----------------------------------------------------------------
Second CustomSlot.cpp 's code :

Qt Code:
  1. #include"CustomSlot2.h"
  2.  
  3. #include "ui_Form2.h"
  4.  
  5.  
  6.  
  7. CustomSlot2::CustomSlot2(QWidget *parent): QWidget(parent)
  8. {
  9. formTwo.setupUi(this);
  10. }
To copy to clipboard, switch view to plain text mode 

Thanks.