Hi all I'm relatively new at this qt programming so please bear with me

What I have been trying to do for hours now is close a login dialog and open a Mainwindow.

On the login Dialog i have a button. What i want is for this button to close the login Dialog (logindialog) and open the main form (userwindow). here's my code so far:

main.cpp:

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


logindialog.h:

Qt Code:
  1. #ifndef LOGINDIALOG_H
  2. #define LOGINDIALOG_H
  3.  
  4. #include <QDialog>
  5.  
  6. namespace Ui {
  7. class LoginDialog;
  8. }
  9.  
  10. class LoginDialog : public QDialog
  11. {
  12. Q_OBJECT
  13.  
  14. public:
  15. explicit LoginDialog(QWidget *parent = 0);
  16. ~LoginDialog();
  17.  
  18. private:
  19. Ui::LoginDialog *ui;
  20.  
  21. private slots:
  22. void on_SubmitButton_clicked();
  23. };
  24.  
  25. #endif // LOGINDIALOG_H
To copy to clipboard, switch view to plain text mode 


userwindow.h:

Qt Code:
  1. #ifndef USERWINDOW_H
  2. #define USERWINDOW_H
  3.  
  4. #include <QMainWindow>
  5.  
  6. namespace Ui {
  7. class UserWindow;
  8. }
  9.  
  10. class UserWindow : public QMainWindow
  11. {
  12. Q_OBJECT
  13.  
  14. public:
  15. explicit UserWindow(QWidget *parent = 0);
  16. ~UserWindow();
  17.  
  18. private:
  19. Ui::UserWindow *ui;
  20. };
  21.  
  22. #endif // USERWINDOW_H
To copy to clipboard, switch view to plain text mode 


logindialog.cpp:

Qt Code:
  1. #include "logindialog.h"
  2. #include "ui_logindialog.h"
  3. #include <QtGui>
  4.  
  5. using namespace std;
  6.  
  7. LoginDialog::LoginDialog(QWidget *parent) :
  8. QDialog(parent),
  9. ui(new Ui::LoginDialog)
  10. {
  11. ui->setupUi(this);
  12. }
  13.  
  14. LoginDialog::~LoginDialog()
  15. {
  16. delete ui;
  17. }
  18.  
  19. void LoginDialog::on_SubmitButton_clicked()
  20. {
  21. /* Code is here for checking username and password
  22.   Want the userwindow to open and the logindialog to close */
  23.  
  24.  
  25.  
  26. }
To copy to clipboard, switch view to plain text mode 

userwindow.cpp:

Qt Code:
  1. #include "userwindow.h"
  2. #include "ui_userwindow.h"
  3.  
  4. UserWindow::UserWindow(QWidget *parent) :
  5. QMainWindow(parent),
  6. ui(new Ui::UserWindow)
  7. {
  8. ui->setupUi(this);
  9. }
  10.  
  11. UserWindow::~UserWindow()
  12. {
  13. delete ui;
  14. }
To copy to clipboard, switch view to plain text mode 


I have tried loads of different things from loads of different posts on loads of different forums. Perhaps i'm doing something fundamentally wrong :S Any code snippets would be greatly appreciated!!


Also on a side note, how come i have to use ui->label->settext() and most of the tutorials just use label->settext() ???

Thanks for your time and trouble. Much appreciated!!