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] Accepted signal from QDialogButtonBox
Forum Updated to NodeBB v4.3 + New Features

[Solved] Accepted signal from QDialogButtonBox

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 6.3k 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
    DarkRoast
    wrote on last edited by
    #1

    Hi all

    I am making a login screen where the user has to enter his username and password. I use a QDialogButtonBox with ok and cancel buttons. My problem is if the user enters incorrect credentials and clicks on the ok button the button is somehow always connected to the accepted signal and closes the dialog.

    What can I do so the dialog wont quit when the user enters incorrect credentials, but instead just clears out the input from the user and lets him try again.

    In .net I would simply do this: DialogResult = DialogResult.None to cancel out the closing of the dialog.

    How can I do this in Qt ?

    Thanks
    DarkRoast

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #2

      Reimplement "QDialog::accept()":http://doc.trolltech.com/4.7/qdialog.html#accept

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DarkRoast
        wrote on last edited by
        #3

        Thanks mlong

        this is how I ended up doing it:

        @void LoginScreen::accept()
        {
        if(LoginToDB())
        {
        done(QDialog::Accepted);
        }
        }

        bool LoginScreen::LoginToDB()
        {
        bool ret = w->LogintoMusicDB(ui->userLineEdit->text(), ui->passwordLineEdit->text());

        if(!ret)
        {
            ui->labelError->setText("Could not log into database!");
        
            ui->userLineEdit->setText("");
            ui->passwordLineEdit->setText("");
        
            return false;
        }
        
        return true;
        

        }@

        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