LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-07-2011, 03:50 AM   #1
Ramurd
Member
 
Registered: Mar 2009
Location: Rotterdam, the Netherlands
Distribution: Slackwarelinux
Posts: 703

Rep: Reputation: 111Reputation: 111
QT: Keep dialog alive after error in onAccepted()


Well, here I am again and not finding how I can get what I want:

I have (for example) a login dialog; it runs fine and does what it is supposed to do, except:
If a user logs on with wrong credentials, how can I keep this window alive? When the onAccepted() is triggered, the window is closed, no matter what. Would/should I have to execute the window again, as in this->exec()?

It seems a bit recursive to me... So, I was hoping I could find a property that would abort the deletion of the window; so I can clear the LineEdit for password and set focus on it... just what a user would expect to happen.

On success the window should close of course, as well as on the cancel button.
 
Old 04-07-2011, 07:33 AM   #2
Ramurd
Member
 
Registered: Mar 2009
Location: Rotterdam, the Netherlands
Distribution: Slackwarelinux
Posts: 703

Original Poster
Rep: Reputation: 111Reputation: 111
hmm... it seems simpler than expected:

PHP Code:
void LoginRemoteDialog::on_buttonBox_accepted()
{
    if(
ui->PasswordInput->text().isEmpty())
    {
        
QMessageBox::critical(this,"Empty password provided""You provided an empty password, that's not nice!");

        
ui->PasswordInput->setFocus();
        
this->show();
    }

Just giving the appropriate input the focus and call show()... can it be this easy?
 
Old 04-07-2011, 03:45 PM   #3
Ramurd
Member
 
Registered: Mar 2009
Location: Rotterdam, the Netherlands
Distribution: Slackwarelinux
Posts: 703

Original Poster
Rep: Reputation: 111Reputation: 111
tested it out on both Linux and Windows, and indeed it is as simple as this. However, MainWindow is shown and then this loginwindow is shown again with the focus where stated.
For niceness' sake, you might also want to set the cursor at the start in the PasswordInput. Marking the thread as solved though :-)
 
  


Reply

Tags
qt cpp c++



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I'm alive scarce10 LinuxQuestions.org Member Intro 1 09-28-2009 10:21 AM
pkgtool - viewing packages fails with dialog error ap0calypse Slackware 13 08-05-2009 08:54 AM
dialog error aneel Linux - General 2 02-15-2006 03:50 PM
dialog error aneel Linux - Software 1 02-15-2006 01:33 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration