Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Problem login window
Forum Updated to NodeBB v4.3 + New Features

Problem login window

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
15 Posts 4 Posters 2.2k 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.
  • jsulmJ jsulm

    @fra_mecc

    ui->button->setEnabled(false);
    

    Where exactly is the problem?

    F Offline
    F Offline
    fra_mecc
    wrote on last edited by
    #5

    @jsulm Sorry, I expressed myself badly. I've already done this. I do not understand how to make Qt understand the login condition

    1 Reply Last reply
    0
    • jsulmJ jsulm

      @fra_mecc

      ui->button->setEnabled(false);
      

      Where exactly is the problem?

      F Offline
      F Offline
      fra_mecc
      wrote on last edited by
      #6

      @jsulm I should define a function (?) so if "Username and password == test" then my icon goes off. But I do not know how to define the function

      ODБOïO 1 Reply Last reply
      0
      • F fra_mecc

        @jsulm I should define a function (?) so if "Username and password == test" then my icon goes off. But I do not know how to define the function

        ODБOïO Offline
        ODБOïO Offline
        ODБOï
        wrote on last edited by
        #7

        @fra_mecc hi,
        Whitch kind of application is this? Could you show your code exemple ?

        one solution could be to having states on your client, ( connected, disconnected )
        Create a boolean bool connected=false;
        then in your connection funtion, if (username=="test" && pass=="test") connected=true

        after this you can use 'connected' as condition

        //qml exemple
        Image{
        source : connected ? "img/disconect.png" : "img/connect.png"
        }

        F 1 Reply Last reply
        0
        • ODБOïO ODБOï

          @fra_mecc hi,
          Whitch kind of application is this? Could you show your code exemple ?

          one solution could be to having states on your client, ( connected, disconnected )
          Create a boolean bool connected=false;
          then in your connection funtion, if (username=="test" && pass=="test") connected=true

          after this you can use 'connected' as condition

          //qml exemple
          Image{
          source : connected ? "img/disconect.png" : "img/connect.png"
          }

          F Offline
          F Offline
          fra_mecc
          wrote on last edited by fra_mecc
          #8

          @LeLev I did not understand much ..I show you the code of dialog file:

          #include "accedi.h"
          #include "ui_accedi.h"
          #include <QMessageBox>
          #include <QLineEdit>
          
          Accedi::Accedi(QWidget *parent) :
              QDialog(parent),
              ui(new Ui::Accedi)
          {
              ui->setupUi(this);
              setWindowTitle("Accedi");
              setWindowIcon(QIcon("accedi.png"));
          }
          
          Accedi::~Accedi()
          {
              delete ui;
          }
          
          void Accedi::on_buttonBox_accepted()
          {
          
          }
          
          void Accedi::on_pushButton_2_clicked()
          {
              hide();
          }
          
          void Accedi::on_pushButton_clicked()
          {
              QString username = ui->lineEdit_username->text();
              QString password = ui->lineEdit_password->text();
          
              if(username == "test" && password == "test") {
                  ui->status->setText("Accesso effettuato.");
                  QMessageBox::information(this, "Accesso effettuato",
                                                 "Bentornato! \nOra potrai usare il programma registrando automaticamente i risultati sul tuo account.");
                  hide();
                  ui->status->clear();
                  ui->status->setText("Connessione...");
                  ui->lineEdit_username->clear();
                  ui->lineEdit_password->clear();
          
          
              }
              else {
                  ui->status->setText("Accesso Negato! Username o password errati");
                  //ui->status->clear();
                  ui->lineEdit_username->clear();
                  ui->lineEdit_password->clear();
          
                  //QMessageBox::warning(this, "Accesso negato", "Username e password sono errati");
              }
          
          
          
          }
          
          ```and this is the part of code of Main Windows (where there is the icon):
          

          }

          void MainWindow::on_actionLogin_2_triggered()
          {
          login->show();
          }

          ODБOïO 1 Reply Last reply
          0
          • F fra_mecc

            @LeLev I did not understand much ..I show you the code of dialog file:

            #include "accedi.h"
            #include "ui_accedi.h"
            #include <QMessageBox>
            #include <QLineEdit>
            
            Accedi::Accedi(QWidget *parent) :
                QDialog(parent),
                ui(new Ui::Accedi)
            {
                ui->setupUi(this);
                setWindowTitle("Accedi");
                setWindowIcon(QIcon("accedi.png"));
            }
            
            Accedi::~Accedi()
            {
                delete ui;
            }
            
            void Accedi::on_buttonBox_accepted()
            {
            
            }
            
            void Accedi::on_pushButton_2_clicked()
            {
                hide();
            }
            
            void Accedi::on_pushButton_clicked()
            {
                QString username = ui->lineEdit_username->text();
                QString password = ui->lineEdit_password->text();
            
                if(username == "test" && password == "test") {
                    ui->status->setText("Accesso effettuato.");
                    QMessageBox::information(this, "Accesso effettuato",
                                                   "Bentornato! \nOra potrai usare il programma registrando automaticamente i risultati sul tuo account.");
                    hide();
                    ui->status->clear();
                    ui->status->setText("Connessione...");
                    ui->lineEdit_username->clear();
                    ui->lineEdit_password->clear();
            
            
                }
                else {
                    ui->status->setText("Accesso Negato! Username o password errati");
                    //ui->status->clear();
                    ui->lineEdit_username->clear();
                    ui->lineEdit_password->clear();
            
                    //QMessageBox::warning(this, "Accesso negato", "Username e password sono errati");
                }
            
            
            
            }
            
            ```and this is the part of code of Main Windows (where there is the icon):
            

            }

            void MainWindow::on_actionLogin_2_triggered()
            {
            login->show();
            }

            ODБOïO Offline
            ODБOïO Offline
            ODБOï
            wrote on last edited by
            #9

            @fra_mecc

            if(username == "test" && password == "test") {
                    ui->status->setText("Accesso effettuato.");
            
            // can't you change your image here ?  ui->yourIcon->setEnabled(false);
            
                    QMessageBox::information(this, "Accesso effettuato",
                                                   "Bentornato! \nOra potrai usare il programma registrando automaticamente i risultati sul tuo account.");
                    hide();
                    ui->status->clear();
                    ui->status->setText("Connessione...");
                    ui->lineEdit_username->clear();
                    ui->lineEdit_password->clear();
            
            
                }
                else {
                    ui->status->setText("Accesso Negato! Username o password errati");
                    //ui->status->clear();
                    ui->lineEdit_username->clear();
                    ui->lineEdit_password->clear();
            
                    //QMessageBox::warning(this, "Accesso negato", "Username e password sono errati");
                }
            
            F 1 Reply Last reply
            1
            • ODБOïO ODБOï

              @fra_mecc

              if(username == "test" && password == "test") {
                      ui->status->setText("Accesso effettuato.");
              
              // can't you change your image here ?  ui->yourIcon->setEnabled(false);
              
                      QMessageBox::information(this, "Accesso effettuato",
                                                     "Bentornato! \nOra potrai usare il programma registrando automaticamente i risultati sul tuo account.");
                      hide();
                      ui->status->clear();
                      ui->status->setText("Connessione...");
                      ui->lineEdit_username->clear();
                      ui->lineEdit_password->clear();
              
              
                  }
                  else {
                      ui->status->setText("Accesso Negato! Username o password errati");
                      //ui->status->clear();
                      ui->lineEdit_username->clear();
                      ui->lineEdit_password->clear();
              
                      //QMessageBox::warning(this, "Accesso negato", "Username e password sono errati");
                  }
              
              F Offline
              F Offline
              fra_mecc
              wrote on last edited by
              #10

              @LeLev ui-> yourIcon->setEnabled(false); it's a piece of code that belongs to the main window while the if loop belongs to a "login" file.
              It does not let me insert the Main Windows code in the other file

              KillerSmathK 1 Reply Last reply
              0
              • F fra_mecc

                @LeLev ui-> yourIcon->setEnabled(false); it's a piece of code that belongs to the main window while the if loop belongs to a "login" file.
                It does not let me insert the Main Windows code in the other file

                KillerSmathK Offline
                KillerSmathK Offline
                KillerSmath
                wrote on last edited by
                #11

                @fra_mecc

                if loop belongs to a "login" file.
                It does not let me insert the Main Windows code in the other file

                You could emit the accept or reject signal of dialog and capture them of mainwindow:
                NOTE: when accept or reject signals are emitted, your dialog is forced to close.

                Login Dialog cpp

                if(username == "test" && password == "test") {
                        ui->status->setText("Accesso effettuato.");
                
                        QMessageBox::information(this, "Accesso effettuato",
                                                       "Bentornato! \nOra potrai usare il programma registrando automaticamente i risultati sul tuo account.");
                        ui->status->clear();
                        ui->status->setText("Connessione...");
                        ui->lineEdit_username->clear();
                        ui->lineEdit_password->clear();
                
                        accept(); // emit accept signal
                    }
                    else {
                        ui->status->setText("Accesso Negato! Username o password errati");
                        ui->lineEdit_username->clear();
                        ui->lineEdit_password->clear();
                
                        //QMessageBox::warning(this, "Accesso negato", "Username e password sono errati");
                    }
                

                main window :

                void MainWindow::on_actionLogin_2_triggered () 
                { 
                  int returnCode = login->exec();
                
                  if(returnCode == QDialog::Accepted)  // returns by accept signal
                     ui->yourIcon->setEnabled(false);
                  else if(dialogCode == QDialog::Rejected)
                     ui->yourIcon->setEnabled(true);
                }
                

                or you can connect thefinished (int)signal of login dialog to a mainwindow slot or lambda function and do the same action.

                @Computer Science Student - Brazil
                Web Developer and Researcher
                “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

                F 2 Replies Last reply
                5
                • KillerSmathK KillerSmath

                  @fra_mecc

                  if loop belongs to a "login" file.
                  It does not let me insert the Main Windows code in the other file

                  You could emit the accept or reject signal of dialog and capture them of mainwindow:
                  NOTE: when accept or reject signals are emitted, your dialog is forced to close.

                  Login Dialog cpp

                  if(username == "test" && password == "test") {
                          ui->status->setText("Accesso effettuato.");
                  
                          QMessageBox::information(this, "Accesso effettuato",
                                                         "Bentornato! \nOra potrai usare il programma registrando automaticamente i risultati sul tuo account.");
                          ui->status->clear();
                          ui->status->setText("Connessione...");
                          ui->lineEdit_username->clear();
                          ui->lineEdit_password->clear();
                  
                          accept(); // emit accept signal
                      }
                      else {
                          ui->status->setText("Accesso Negato! Username o password errati");
                          ui->lineEdit_username->clear();
                          ui->lineEdit_password->clear();
                  
                          //QMessageBox::warning(this, "Accesso negato", "Username e password sono errati");
                      }
                  

                  main window :

                  void MainWindow::on_actionLogin_2_triggered () 
                  { 
                    int returnCode = login->exec();
                  
                    if(returnCode == QDialog::Accepted)  // returns by accept signal
                       ui->yourIcon->setEnabled(false);
                    else if(dialogCode == QDialog::Rejected)
                       ui->yourIcon->setEnabled(true);
                  }
                  

                  or you can connect thefinished (int)signal of login dialog to a mainwindow slot or lambda function and do the same action.

                  F Offline
                  F Offline
                  fra_mecc
                  wrote on last edited by
                  #12
                  This post is deleted!
                  1 Reply Last reply
                  0
                  • KillerSmathK KillerSmath

                    @fra_mecc

                    if loop belongs to a "login" file.
                    It does not let me insert the Main Windows code in the other file

                    You could emit the accept or reject signal of dialog and capture them of mainwindow:
                    NOTE: when accept or reject signals are emitted, your dialog is forced to close.

                    Login Dialog cpp

                    if(username == "test" && password == "test") {
                            ui->status->setText("Accesso effettuato.");
                    
                            QMessageBox::information(this, "Accesso effettuato",
                                                           "Bentornato! \nOra potrai usare il programma registrando automaticamente i risultati sul tuo account.");
                            ui->status->clear();
                            ui->status->setText("Connessione...");
                            ui->lineEdit_username->clear();
                            ui->lineEdit_password->clear();
                    
                            accept(); // emit accept signal
                        }
                        else {
                            ui->status->setText("Accesso Negato! Username o password errati");
                            ui->lineEdit_username->clear();
                            ui->lineEdit_password->clear();
                    
                            //QMessageBox::warning(this, "Accesso negato", "Username e password sono errati");
                        }
                    

                    main window :

                    void MainWindow::on_actionLogin_2_triggered () 
                    { 
                      int returnCode = login->exec();
                    
                      if(returnCode == QDialog::Accepted)  // returns by accept signal
                         ui->yourIcon->setEnabled(false);
                      else if(dialogCode == QDialog::Rejected)
                         ui->yourIcon->setEnabled(true);
                    }
                    

                    or you can connect thefinished (int)signal of login dialog to a mainwindow slot or lambda function and do the same action.

                    F Offline
                    F Offline
                    fra_mecc
                    wrote on last edited by
                    #13

                    @KillerSmath Resolved! Thanks so much! I do not know how to thank you..

                    ODБOïO jsulmJ 2 Replies Last reply
                    3
                    • F fra_mecc

                      @KillerSmath Resolved! Thanks so much! I do not know how to thank you..

                      ODБOïO Offline
                      ODБOïO Offline
                      ODБOï
                      wrote on last edited by
                      #14

                      @fra_mecc up vote him :p

                      1 Reply Last reply
                      2
                      • F fra_mecc

                        @KillerSmath Resolved! Thanks so much! I do not know how to thank you..

                        jsulmJ Offline
                        jsulmJ Offline
                        jsulm
                        Lifetime Qt Champion
                        wrote on last edited by
                        #15

                        @fra_mecc Keep in mind that it is very easy to find the user name and password in your executable. So, if an user with a bit of knowledge gets your app he/she will extract the user name and password from the executable file.

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply
                        2

                        • Login

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