• Hi
    I need some help .. i have two windows ( mainwindow.ui ) and ( Dialog.ui) ... how i can Switching between the two windows?? and Hide the main window when the Dialog window appear and vice versa ..

    I will be Grateful for any Help..

  • You mean something like thgis?:
    @uDialog *usrDialog = new uDialog(this);

  • Well thanks, i used this in void MainWindow::on_pushButton_clicked()

    @Dialog mDialog ;

    Now how i can back to main window by press on the back Button ( void Dialog::on_pushButton_clicked() ) in the dialog window ??


  • I am not sure that i understand you. Correct me if i'm wrong.
    You want create wizzard like app? If yes look at "http://qt-project.org/doc/qt-4.8/qwizard.html":http://qt-project.org/doc/qt-4.8/qwizard.html
    Or if you asking how close dialog window by pressing back button then:
    in push button slot.

  • Thanks Mate. :) exactly this is what i was need to know .. Thanks again for your help

  • You're welcome!
    feel free asks any new questions.

  • Cool, So you will can help me in other thing. i need to put logging in the main window ( username and password ) if correct allow to go to the next window else appear error.. So i can doing that's ??


  • Hi!
    There are many ways to doing that. It depends of architecture of you project.

    1. variant:
      Make login dialog window as your main window, and put into it some login pass check function:
      @if(checkLogin(login, pass)){
      Dialog mDialog ;
      QMessageBox::information(this, tr("Caption"), tr("Error text"), QMessageBox::Ok);

    2. variant:
      Make login dialog window as child of your main window. Put somewhere "login" menu or button:
      Dialog mLoginDialog ;
      if(checkLogin(mLoginDialog.getLogin(), mLoginDialog.getPassword())){
      //some ini actions
      QMessageBox::information(this, tr("Caption"), tr("Error text"), QMessageBox::Ok);

    3. variant:
      Make two separate windows and put login check in main() function:

    @int main(int argc, char *argv[])
    QApplication a(argc, argv);
    LoginDialog ld;
    if(ld.exec() == QDialog::Accepted){
    MainWindow w;

    return a.exec();


    But i belive everybody doing this in their own way :)

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.