Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Trouble with QStackedWidget
QtWS25 Last Chance

Trouble with QStackedWidget

Scheduled Pinned Locked Moved Solved General and Desktop
qstackedwidgetloginconstructor
2 Posts 2 Posters 1.1k 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.
  • cxamC Offline
    cxamC Offline
    cxam
    wrote on last edited by
    #1

    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;
    }
    

    Stay Hungry, Stay Foolish

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      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