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.3k 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.
  • J jsulm
    29 Jun 2018, 05:29

    @fra_mecc http://doc.qt.io/qt-5/qwidget.html#enabled-prop

    F Offline
    F Offline
    fra_mecc
    wrote on 29 Jun 2018, 12:26 last edited by
    #3

    @jsulm said in Problem login window:

    @fra_mecc http://doc.qt.io/qt-5/qwidget.html#enabled-prop

    Thank you so much but I still do not understand how I can tell Qt that the icono must go off if the condition (username and password == "test")

    J 1 Reply Last reply 29 Jun 2018, 12:27
    0
    • F fra_mecc
      29 Jun 2018, 12:26

      @jsulm said in Problem login window:

      @fra_mecc http://doc.qt.io/qt-5/qwidget.html#enabled-prop

      Thank you so much but I still do not understand how I can tell Qt that the icono must go off if the condition (username and password == "test")

      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 29 Jun 2018, 12:27 last edited by
      #4

      @fra_mecc

      ui->button->setEnabled(false);
      

      Where exactly is the problem?

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

      F 2 Replies Last reply 29 Jun 2018, 12:45
      2
      • J jsulm
        29 Jun 2018, 12:27

        @fra_mecc

        ui->button->setEnabled(false);
        

        Where exactly is the problem?

        F Offline
        F Offline
        fra_mecc
        wrote on 29 Jun 2018, 12:45 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
        • J jsulm
          29 Jun 2018, 12:27

          @fra_mecc

          ui->button->setEnabled(false);
          

          Where exactly is the problem?

          F Offline
          F Offline
          fra_mecc
          wrote on 29 Jun 2018, 13:16 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

          O 1 Reply Last reply 29 Jun 2018, 13:41
          0
          • F fra_mecc
            29 Jun 2018, 13:16

            @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

            O Offline
            O Offline
            ODБOï
            wrote on 29 Jun 2018, 13:41 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 29 Jun 2018, 13:48
            0
            • O ODБOï
              29 Jun 2018, 13:41

              @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 29 Jun 2018, 13:48 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();
              }

              O 1 Reply Last reply 29 Jun 2018, 14:13
              0
              • F fra_mecc
                29 Jun 2018, 13:48

                @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();
                }

                O Offline
                O Offline
                ODБOï
                wrote on 29 Jun 2018, 14:13 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 29 Jun 2018, 14:30
                1
                • O ODБOï
                  29 Jun 2018, 14:13

                  @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 29 Jun 2018, 14:30 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

                  K 1 Reply Last reply 29 Jun 2018, 15:25
                  0
                  • F fra_mecc
                    29 Jun 2018, 14:30

                    @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

                    K Offline
                    K Offline
                    KillerSmath
                    wrote on 29 Jun 2018, 15:25 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 29 Jun 2018, 16:49
                    5
                    • K KillerSmath
                      29 Jun 2018, 15:25

                      @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 29 Jun 2018, 16:49 last edited by
                      #12
                      This post is deleted!
                      1 Reply Last reply
                      0
                      • K KillerSmath
                        29 Jun 2018, 15:25

                        @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 29 Jun 2018, 17:00 last edited by
                        #13

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

                        O J 2 Replies Last reply 29 Jun 2018, 17:18
                        3
                        • F fra_mecc
                          29 Jun 2018, 17:00

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

                          O Offline
                          O Offline
                          ODБOï
                          wrote on 29 Jun 2018, 17:18 last edited by
                          #14

                          @fra_mecc up vote him :p

                          1 Reply Last reply
                          2
                          • F fra_mecc
                            29 Jun 2018, 17:00

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

                            J Offline
                            J Offline
                            jsulm
                            Lifetime Qt Champion
                            wrote on 2 Jul 2018, 04:25 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

                            12/15

                            29 Jun 2018, 16:49

                            • Login

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