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. [Solved]login form enter key not working
Forum Updated to NodeBB v4.3 + New Features

[Solved]login form enter key not working

Scheduled Pinned Locked Moved General and Desktop
9 Posts 4 Posters 3.4k Views 1 Watching
  • 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.
  • D Offline
    D Offline
    devfeel
    wrote on 29 Aug 2012, 04:53 last edited by
    #1

    Hi,
    I have a login form, when user enters user name and password it will open second form..but wen i click enter nothing happens...when i click enter key it should go to this function..how to do it..please help
    [CODE]
    void login::on_ok_clicked()
    {
    if(ui->u_name->text()=="a" && ui->pwd->text()=="a")
    {
    //hide();
    qWarning("Login Sucessful");
    }
    else
    {
    ui->statusBar->showMessage("Login Failure");
    }
    }
    [/CODE]

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Sam
      wrote on 29 Aug 2012, 05:17 last edited by
      #2

      In order to achieve that you can try

      @okButton->setDefault(true)@

      check "QPushButton::setDefault()":http://doc.qt.nokia.com/4.7-snapshot/qpushbutton.html#default-prop

      Edit: This works for a QDialog

      1 Reply Last reply
      0
      • D Offline
        D Offline
        devfeel
        wrote on 29 Aug 2012, 06:02 last edited by
        #3

        It didnt work i tried sam, I am using QMainWindow...Is there any way to make it work in qmainwindow or should i have to change to qdialog...?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Sam
          wrote on 29 Aug 2012, 06:20 last edited by
          #4

          It works for QDialog as per the documentation. In order to work for the QMainWindow you can override/handle the keyPressEvent().

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Jeroentjehome
            wrote on 29 Aug 2012, 09:00 last edited by
            #5

            It might be a good idea to use a QDialog to handle this. Then give the dialog a parent (your main window). You MainWindow file will then be must shorter (if you make the dialog in it's own cpp file etc). In the MainWindow you won't be bothered by the signals (Done in the QDialog) etc.
            Might look like this:
            @
            QYourDialog LoginBox = new QYourDialog;
            if (LoginBox->exec() == QDialog::Accepted)
            {
            if (LoginBox->u_name->text() == "a")
            {
            // Oke??
            }
            else
            { // Wrong??
            }
            }@

            Greetz, Jeroen

            1 Reply Last reply
            0
            • D Offline
              D Offline
              devfeel
              wrote on 30 Aug 2012, 10:50 last edited by
              #6

              thanks jeroentje & sam

              1 Reply Last reply
              0
              • S Offline
                S Offline
                Sam
                wrote on 30 Aug 2012, 11:42 last edited by
                #7

                Did you get it working. If yes then Kindly edit your first post and add [Solved] to the title.

                Happy Coding!!!!

                1 Reply Last reply
                0
                • D Offline
                  D Offline
                  devfeel
                  wrote on 31 Aug 2012, 09:07 last edited by
                  #8

                  Ya working sam, used qdialog....

                  1 Reply Last reply
                  0
                  • Y Offline
                    Y Offline
                    yupifourbi
                    wrote on 19 Nov 2012, 04:30 last edited by
                    #9

                    Dear Jeroentje,

                    Would you mind to share the QYourDialog code?

                    Thanks in advance.

                    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