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:
Code:
#include <QtGui/QApplication> #include "logindialog.h" int main(int argc, char *argv[]) { LoginDialog w; w.show(); return a.exec(); }
logindialog.h:
Code:
#ifndef LOGINDIALOG_H #define LOGINDIALOG_H #include <QDialog> namespace Ui { class LoginDialog; } { Q_OBJECT public: ~LoginDialog(); private: Ui::LoginDialog *ui; private slots: void on_SubmitButton_clicked(); }; #endif // LOGINDIALOG_H
userwindow.h:
Code:
#ifndef USERWINDOW_H #define USERWINDOW_H #include <QMainWindow> namespace Ui { class UserWindow; } { Q_OBJECT public: ~UserWindow(); private: Ui::UserWindow *ui; }; #endif // USERWINDOW_H
logindialog.cpp:
Code:
#include "logindialog.h" #include "ui_logindialog.h" #include <QtGui> using namespace std; ui(new Ui::LoginDialog) { ui->setupUi(this); } LoginDialog::~LoginDialog() { delete ui; } void LoginDialog::on_SubmitButton_clicked() { /* Code is here for checking username and password Want the userwindow to open and the logindialog to close */ }
userwindow.cpp:
Code:
#include "userwindow.h" #include "ui_userwindow.h" ui(new Ui::UserWindow) { ui->setupUi(this); } UserWindow::~UserWindow() { delete ui; }
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!! :)