[Qt-interest] Hiding a QDialog?

Samuel Gaist samuel.gaist at cinetis.ch
Wed Jun 30 10:03:26 CEST 2010


Hello Scott,
I had to to something similar in an application, i didn't use hide()  
on the dialog but setVisible(bool), so that the event loop was still  
running and i could bring back the dialog.

I know that does not answer directly your question but might give you  
another idea to achieve what you want.
Samuel

On 30 juin 10, at 06:06, Scott Aron Bloom wrote:

> But I am trying to hide the complete dialog.  I want the whole  
> dialog to hide while the actual processing of the dialogs data  
> occurs..
>
> Once its done processing if everything went ok, accept is called.
>
> If something went wrong during the processing, the dialog is  
> reshown. And the cycle can begin again.
>
> Scott
>
> From: prashant bhutani [mailto:prashantbhutani2008 at gmail.com]
> Sent: Tuesday, June 29, 2010 9:03 PM
> To: Scott Aron Bloom
> Subject: Re: [Qt-interest] Hiding a QDialog?
>
> Try btn->hide() and btn->show() instead of simple hide and show
>
> On Wed, Jun 30, 2010 at 3:36 AM, Scott Aron Bloom <Scott.Bloom at onshorecs.com 
> > 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?
>
> Scott
>
> PS. Here is code to duplicate the problem’
>
> #include <QApplication>
> #include <QPushButton>
> #include <QMessageBox>
> #include <QVBoxLayout>
> #include <QLabel>
>
> class Dialog : public QDialog
> {
> public:
>       Dialog( QWidget * parent=NULL ) :
>             QDialog( parent )
>       {
>             QLabel * label = new QLabel( "Hello World" );
>             QPushButton * btn = new QPushButton( "Push Here" );
>             connect( btn, SIGNAL( clicked() ), this,  
> SLOT( accept() ) );
>
>             QVBoxLayout * layout = new QVBoxLayout( this );
>             layout->addWidget( label );
>             layout->addWidget( btn );
>       }
>
>       virtual void accept()
>       {
>             hide(); // comment this out, and everything works
>             QMessageBox::warning( this, "Error logging in",  
> QString( "The user credentials don't match. Please check user name  
> and password" ) );
>             show();
>             return;
>       }
> };
>
> int main( int argc, char ** argv)
> {
>       QApplication appl( argc, argv );
>       Dialog dlg;
>       int retVal = dlg.exec();
>       return retVal;
> }
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
> -- 
> Prashant Bhutani
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100630/246cfb24/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 1587 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100630/246cfb24/attachment.bin 


More information about the Qt-interest-old mailing list