PDA

View Full Version : exec() not blocking, derived QDialog, Qt 4.4.3



wdezell
4th August 2009, 00:18
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:

MyDialogClass *dialog = new MyDialogClass ( parent_ptr, other params );
dialog->exec ( );

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

wdezell
4th August 2009, 18:49
In case it sheds any light on the problem for anyone here are my two source files (as simple as they get):

Class declaration

#include "ui_ppdl_dialogMissingFiles.h"
#include <QString>
#include <QDebug>

class PpdlDialogMissingFiles : public QDialog, public Ui::PpdlDialogMissingFiles {
Q_OBJECT

public:
PpdlDialogMissingFiles( QWidget *parent = 0, const QString &bodyhtml = "" );
~PpdlDialogMissingFiles( );

private:
QString html; // build string for preparing QTextEdit html

};

Class implementation


#include "ppdl_dialogMissingFiles.h"
#include <QTextStream>

// constructor
PpdlDialogMissingFiles::PpdlDialogMissingFiles ( QWidget * parent, const QString &bodyhtml ):QDialog ( parent )
{
setupUi ( this );

// wrap the passed body text in HTML framework
QTextStream ( &html ) << "<html><head></head><body>" << bodyhtml << "</body></html>";

// display the content provided to us
textEdit->setHtml ( html );
}

// destructor
PpdlDialogMissingFiles::~PpdlDialogMissingFiles ( )
{
// nothing for now
}

Invocation from app that encounters exec() block failure (returns immediately with '0')


// missingFilesAdvisory is a populated QString
// also no change when parented to app QMainWindow instead of '0'
PpdlDialogMissingFiles *dialogMissingFiles = new PpdlDialogMissingFiles ( 0, missingFilesAdvisory );

// returns Yes (Proceed) = 1, No (Do not proceed) = 0
int proceed = dialogMissingFiles->exec ( );

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

wdezell
4th August 2009, 19:56
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.