Results 1 to 3 of 3

Thread: exec() not blocking, derived QDialog, Qt 4.4.3

  1. #1
    Join Date
    Mar 2009
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Angry exec() not blocking, derived QDialog, Qt 4.4.3

    I'm continuing development of an app begun under Qt 4.3.3 (X11), now building using Qt 4.4.3 from source. I've just added a new, simple custom dialog ( Yes/No QButtonBox and a read-only QTextEdit). I created the dialog using Qt Creator 1.2.1 (source distro) choosing a subclassed-based approach. The resulting .h/.cpp class output files are nearly identical to what I've been coding by hand (Creator is great!).

    My dialog is supposed to be Qt::ApplicationModal. Like other dialogs I've coded by hand, I invoke it similar to the following:
    Qt Code:
    1. MyDialogClass *dialog = new MyDialogClass ( parent_ptr, other params );
    2. dialog->exec ( );
    To copy to clipboard, switch view to plain text mode 

    The problem is that my dialog is exiting immediately (briefly visible) with a Reject (0) return value as if exec() never gets hooked into the application event loop. Stepping through with debug corroborates this. qDebug()'s sprinkled in my constructor show me that it's executing and receiving valid & expected params. When I drop my class over in a simple test project (invoked before qApp.exec() ) it displays fine with test data and returns the right Yes/No codes.

    I'm a bit baffled and can't figure out what's wrong. Other custom dialogs still work perfect so it's me, not Qt. Any suggestions?

    Bill

  2. #2
    Join Date
    Mar 2009
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: exec() not blocking, derived QDialog, Qt 4.4.3

    In case it sheds any light on the problem for anyone here are my two source files (as simple as they get):

    Class declaration
    Qt Code:
    1. #include "ui_ppdl_dialogMissingFiles.h"
    2. #include <QString>
    3. #include <QDebug>
    4.  
    5. class PpdlDialogMissingFiles : public QDialog, public Ui::PpdlDialogMissingFiles {
    6. Q_OBJECT
    7.  
    8. public:
    9. PpdlDialogMissingFiles( QWidget *parent = 0, const QString &bodyhtml = "" );
    10. ~PpdlDialogMissingFiles( );
    11.  
    12. private:
    13. QString html; // build string for preparing QTextEdit html
    14.  
    15. };
    To copy to clipboard, switch view to plain text mode 

    Class implementation
    Qt Code:
    1. #include "ppdl_dialogMissingFiles.h"
    2. #include <QTextStream>
    3.  
    4. // constructor
    5. PpdlDialogMissingFiles::PpdlDialogMissingFiles ( QWidget * parent, const QString &bodyhtml ):QDialog ( parent )
    6. {
    7. setupUi ( this );
    8.  
    9. // wrap the passed body text in HTML framework
    10. QTextStream ( &html ) << "<html><head></head><body>" << bodyhtml << "</body></html>";
    11.  
    12. // display the content provided to us
    13. textEdit->setHtml ( html );
    14. }
    15.  
    16. // destructor
    17. PpdlDialogMissingFiles::~PpdlDialogMissingFiles ( )
    18. {
    19. // nothing for now
    20. }
    To copy to clipboard, switch view to plain text mode 

    Invocation from app that encounters exec() block failure (returns immediately with '0')
    Qt Code:
    1. // missingFilesAdvisory is a populated QString
    2. // also no change when parented to app QMainWindow instead of '0'
    3. PpdlDialogMissingFiles *dialogMissingFiles = new PpdlDialogMissingFiles ( 0, missingFilesAdvisory );
    4.  
    5. // returns Yes (Proceed) = 1, No (Do not proceed) = 0
    6. int proceed = dialogMissingFiles->exec ( );
    To copy to clipboard, switch view to plain text mode 

    Other custom dialogs of similar design working fine. This working fine in a test app. Fails in my main app. What am I not seeing?

    Thanks to all,
    Bill

  3. #3
    Join Date
    Mar 2009
    Posts
    19
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: exec() not blocking, derived QDialog, Qt 4.4.3

    Update

    I moved my source tree to a Qt 4.3.3 development box and the custom dialog works fine.

    I do not want to be hasty in making assumptions but it sure seems like Qt 4.4.3 is at fault -- either something is broken or some aspect of usage/syntax has changed.

    I'm ditching 4.4.3 and falling back to 4.3.3 for now.

Similar Threads

  1. QDialog derived and focus problem
    By elm66 in forum Qt Programming
    Replies: 1
    Last Post: 4th April 2008, 21:52
  2. QDialog: show() and exec() together in constructor?
    By Teuniz in forum Qt Programming
    Replies: 8
    Last Post: 28th February 2007, 11:43

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.