Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Switching
QtWS25 Last Chance

Switching

Scheduled Pinned Locked Moved Mobile and Embedded
8 Posts 2 Posters 2.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tariq
    wrote on last edited by
    #1

    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..

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qxoz
      wrote on last edited by
      #2

      You mean something like thgis?:
      @uDialog *usrDialog = new uDialog(this);
      this->setVisible(false);
      usrDialog->exec();
      this->setVisible(true);@

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tariq
        wrote on last edited by
        #3

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

        @Dialog mDialog ;
        this->setVisible(false);
        mDialog.exec();
        this->setVisible(true);@

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

        Regards.

        1 Reply Last reply
        0
        • Q Offline
          Q Offline
          qxoz
          wrote on last edited by
          #4

          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:
          @this->close()@
          in push button slot.

          1 Reply Last reply
          0
          • T Offline
            T Offline
            tariq
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0
            • Q Offline
              Q Offline
              qxoz
              wrote on last edited by
              #6

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

              1 Reply Last reply
              0
              • T Offline
                T Offline
                tariq
                wrote on last edited by
                #7

                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 ??

                Regards

                1 Reply Last reply
                0
                • Q Offline
                  Q Offline
                  qxoz
                  wrote on last edited by
                  #8

                  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 ;
                    this->setVisible(false);
                    mDialog.exec();
                    this->setVisible(true);
                    }else{
                    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 ;
                    mLoginDialog.exec();
                    if(checkLogin(mLoginDialog.getLogin(), mLoginDialog.getPassword())){
                    //some ini actions
                    }else{
                    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;
                  w.show();
                  }

                  return a.exec();
                  

                  }@

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

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved