[Qt-interest] Hiding a QDialog?

Scott Aron Bloom Scott.Bloom at onshorecs.com
Wed Jun 30 11:07:44 CEST 2010


Yes and no.. Its one of those damned if you do, damned if you don't...

 

My login dialog is self contained from a client point of view.. All you do is exec, and it does the login for you, makes sure the id is valid, etc etc...

 

Doing a "while" loop as proposed earlier, would work, where all it did was get the settings form the user, then main.cpp (which is where its called from before the mainwindow iscreated) would simply get the info from the dialog, and have a validator class to do the SQL calls to login...

 

Definitely doable..  and I have done it this way before...

 

This login was implemented this way, a while back.. it made sense then.. My client wanted a "splash screen", which was easy enough to implement using QSplashScreen.

 

However, once the user hits "ok" or the auto timer times out and accept is hit, now any messages (there are about 4 stages to the login) now go to the splash screen rather than the progress dialog that used to exist...


Honestly, the progress dialog ontop of the login, looked fine.. but ugly ontop of the splash screen..  So hiding the login looks GREAT..


However, if one of the steps fails, the login comes back up after a QMEssageBox is displayed...  Unfortunately, that's when the dang event loop bug came up L

 

So your solution is definitely the way to go... however, I do consider this a bug.  I understand WHY the code stops the event loop if its hidden.. Since a dialog box that is modal, has its own event loop, if you hide it, and the event loop is running, user input wont go anywhere since the dialog getting the eventloop is hidden...

 

I think the bug is, that when you show the dialog after the hide, it doesn't restart the event loop.

 

Scott

 

From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Andre Somers
Sent: Wednesday, June 30, 2010 1:30 AM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] Hiding a QDialog?

 

Hi Scott,

On 30-6-2010 0:06, Scott Aron Bloom wrote: 

I have a startup/login dialog, that after the user hits OK, I would like to hide(), showing messages onto the QSplashScreen.

 

If however, there is a problem logging in, a message box pops up, then I show() dialog and would like to continue.

 

Here is the rub, when you hide a dialog, it sets the exit flag in the QDialog's event loop.  So the next time the dialogs event loop cycles, it exits out.

 

Is there anyway, to restart the event loop? 

 

Interesting problem. I had no idea that calling hide() on a QDialog would trigger the exit of its eventloop...

Wouldn't it make sense to separate your logic a bit? You could have your dialog just be the UI for entering the credentials. Another class could be responsible for checking them. That way, you can have that credentials class pop up the dialog for entering the credentials as often as you need. You can have all logic having to do with the status of the login in that single credentials class, including stuff like caching, timeout, etc. 

André




-- 
Nokia Certified Qt Developer.
Interested in Qt related job offers or freelance Qt consulting work.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100630/f6983f6b/attachment.html 


More information about the Qt-interest-old mailing list