Trouble with QStackedWidget



  • Hi!
    I just started working and gaining confidence with the QStackedWidget but now I'm facing a little problem, when my login finishes out succesfully it sets the currentindex of the qstackedwidget to my next widget (a mainmenu) and then you have several options. The problem I'm having is that the program jumps directly to a menu option skipping the login window and the main menu window. Here's my code:

    /******************************
     *
     *      LOGIN PROCESS
     *
     * ****************************/
    
    void MainWindow::on_contrasegna_textChanged(const QString &arg1){
        introducedpass = arg1;
    }
    
    void MainWindow::on_usuario_textChanged(const QString &arg1){
        introduceduser = arg1;
    }
    
    void MainWindow::EntrarFunction(int entrar){
        ui->stackedWidget->setCurrentIndex(entrar);
    
        if (user == introduceduser){
            if (password == introducedpass){
                ui->stackedWidget->setCurrentIndex(menu);
            }else{
                QMessageBox messageBox;
                messageBox.critical(0,"Error","ContraseƱa Incorrecta");
                messageBox.setFixedSize(500,200);
            }
        }else{
            QMessageBox messageBox;
            messageBox.critical(0,"Error","Usuario Incorrecto");
            messageBox.setFixedSize(500,200);
        }
    }
    
    void MainWindow::on_EntrarBT_clicked(){
        EntrarFunction(entrar);
    }
    
    
    
    /******************************
     *
     *      MAIN MENU
     *
     * ****************************/
    
    
    void MainWindow::setPage(int index){
        index = currentpage;
        ui->stackedWidget->setCurrentIndex(index);
    }
    
    void MainWindow::on_usuariosBT_clicked(){
        currentpage = usuarios;
    }
    

  • Lifetime Qt Champion

    Hi,

    Since you marked it solved, can you share what you did to fix your code ?


Log in to reply
 

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