mclark
3rd October 2008, 17:01
I've recently updated my Qt installation from 4.3.4 to 4.4.2. I have a simple dialog which is to display a 1 line message while some time-consuming operation is happening. When the operation has finished the dialog closes.
Using 4.3.4 this was displaying as expected but since my switch to 4.4.2 the dialog body has become transparent (no background color, no text).
Based on my years of programming experience:rolleyes:, I assume that my code has worked by accident in 4.3.4 and 4.4.2 has uncovered a defect. Can anyone see what is going wrong here?
I've attached a bitmap of what I'm seeing.
class GenericWaitDlg : public QDialog
{
Q_OBJECT
public:
GenericWaitDlg( QWidget *pParent );
void Initialize( QString sTitle, QString sMsg );
private:
Ui::GenericDlgClass ui;
QWidget* m_pParent;
MainWin* m_pMainWin;
};
GenericWaitDlg::GenericWaitDlg( QWidget* pParent )
: QDialog( pParent )
, m_pParent( pParent )
, m_pMainWin( reinterpret_cast<MainWin*>(
reinterpret_cast<NetConfigDlg*>( pParent )->m_pMainWin ) ) {}
void GenericWaitDlg::Initialize( QString sTitle, QString sMsg )
{
// Remove the system menu, close button and context help button
setWindowFlags( windowFlags() ^
(Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint) );
ui.setupUi( this );
// Create Title and text strings
setWindowTitle( sTitle );
QLabel* sText = new QLabel( sMsg, this );
// Get the label size and use to fix dialog width
QSize labelSize = sText->sizeHint().expandedTo( sText->sizeHint() );
labelSize.setWidth( labelSize.width() + 120 );
// Layout label
QHBoxLayout* hBox = new QHBoxLayout();
hBox->addWidget( sText, 0, Qt::AlignHCenter );
// Main layout
QVBoxLayout* vbox = new QVBoxLayout( this );
vbox->addSpacing( 10 );
vbox->addLayout( hBox, Qt::AlignRight );
vbox->addSpacing( 15 );
setLayout( vbox );
resize( labelSize.width(), labelSize.height() * 8 );
// Center the dialog in the parent window
move( m_pParent->pos().x() +
(m_pParent->frameGeometry().width() / 2) - (frameGeometry().width() / 2),
m_pParent->pos().y() +
(m_pParent->frameGeometry().height() / 2) - (frameGeometry().height() / 2) );
}
// Instantiate, initialize and show the dialog
GenericWaitDlg dlg( m_parent );
dlg.Initialize( DLG_TITLE, DLG_MSG );
dlg.show();
// Do some work here...
dlg.done( 0 );
Using 4.3.4 this was displaying as expected but since my switch to 4.4.2 the dialog body has become transparent (no background color, no text).
Based on my years of programming experience:rolleyes:, I assume that my code has worked by accident in 4.3.4 and 4.4.2 has uncovered a defect. Can anyone see what is going wrong here?
I've attached a bitmap of what I'm seeing.
class GenericWaitDlg : public QDialog
{
Q_OBJECT
public:
GenericWaitDlg( QWidget *pParent );
void Initialize( QString sTitle, QString sMsg );
private:
Ui::GenericDlgClass ui;
QWidget* m_pParent;
MainWin* m_pMainWin;
};
GenericWaitDlg::GenericWaitDlg( QWidget* pParent )
: QDialog( pParent )
, m_pParent( pParent )
, m_pMainWin( reinterpret_cast<MainWin*>(
reinterpret_cast<NetConfigDlg*>( pParent )->m_pMainWin ) ) {}
void GenericWaitDlg::Initialize( QString sTitle, QString sMsg )
{
// Remove the system menu, close button and context help button
setWindowFlags( windowFlags() ^
(Qt::WindowSystemMenuHint | Qt::WindowContextHelpButtonHint) );
ui.setupUi( this );
// Create Title and text strings
setWindowTitle( sTitle );
QLabel* sText = new QLabel( sMsg, this );
// Get the label size and use to fix dialog width
QSize labelSize = sText->sizeHint().expandedTo( sText->sizeHint() );
labelSize.setWidth( labelSize.width() + 120 );
// Layout label
QHBoxLayout* hBox = new QHBoxLayout();
hBox->addWidget( sText, 0, Qt::AlignHCenter );
// Main layout
QVBoxLayout* vbox = new QVBoxLayout( this );
vbox->addSpacing( 10 );
vbox->addLayout( hBox, Qt::AlignRight );
vbox->addSpacing( 15 );
setLayout( vbox );
resize( labelSize.width(), labelSize.height() * 8 );
// Center the dialog in the parent window
move( m_pParent->pos().x() +
(m_pParent->frameGeometry().width() / 2) - (frameGeometry().width() / 2),
m_pParent->pos().y() +
(m_pParent->frameGeometry().height() / 2) - (frameGeometry().height() / 2) );
}
// Instantiate, initialize and show the dialog
GenericWaitDlg dlg( m_parent );
dlg.Initialize( DLG_TITLE, DLG_MSG );
dlg.show();
// Do some work here...
dlg.done( 0 );