sterling
8th January 2014, 21:44
I am creating a widget that is similar to another created in a different GUI.
If I do basewin->show() in the constructor, I get what I expect to see, the widget is displayed.
The constructor code is below.
ProgressBar::ProgressBar( QWidget *parent )
: QWidget(parent)
{
QRect newrct;
QRect qrct = parent->geometry();
basewin = new QDialog( this, Qt::Dialog );
if( parent == NULL )
{ basewin->setGeometry( QRect( BW_TOP, BW_LEFT, BW_BOTTOM - BW_TOP, BW_RIGHT - BW_LEFT ) ); }
else
{
// Set relative to the container
//
newrct.setTop( 0 );
newrct.setHeight( BW_BOTTOM - BW_TOP );
newrct.setLeft( 0 );
newrct.setWidth( BW_RIGHT - BW_LEFT );
basewin->setGeometry( newrct );
basewin->move( QPoint( qrct.left() + 20, qrct.top() + 20 ) );
}
QProgressBar *mybar = new QProgressBar( basewin );
mybar->setGeometry( QRect( 10, 30, (BW_RIGHT - BW_LEFT), 25 ) );
basewin->show();
}
If I comment out the basewin->show() in the constructor and enable the pb.show() as below in the application test, the widget doesn't display.
void TestRig::TestProgress( void )
{
ProgressBar pb( this );
pb.SetWindowTitle( "Progress bar title" );
// pb.show();
xvt_dm_post_note( "Test Progress: Any Key To Continue" );
}
What am I missing here. Should not the pb.show() in the application cause the widget to display.
The reason I need this behavior is that there are other items that have to be setup before the pb widget is displayed. Other controls may or may not be inserted and the geometry needs to be adjusted prior to the actual display.
Thanks
If I do basewin->show() in the constructor, I get what I expect to see, the widget is displayed.
The constructor code is below.
ProgressBar::ProgressBar( QWidget *parent )
: QWidget(parent)
{
QRect newrct;
QRect qrct = parent->geometry();
basewin = new QDialog( this, Qt::Dialog );
if( parent == NULL )
{ basewin->setGeometry( QRect( BW_TOP, BW_LEFT, BW_BOTTOM - BW_TOP, BW_RIGHT - BW_LEFT ) ); }
else
{
// Set relative to the container
//
newrct.setTop( 0 );
newrct.setHeight( BW_BOTTOM - BW_TOP );
newrct.setLeft( 0 );
newrct.setWidth( BW_RIGHT - BW_LEFT );
basewin->setGeometry( newrct );
basewin->move( QPoint( qrct.left() + 20, qrct.top() + 20 ) );
}
QProgressBar *mybar = new QProgressBar( basewin );
mybar->setGeometry( QRect( 10, 30, (BW_RIGHT - BW_LEFT), 25 ) );
basewin->show();
}
If I comment out the basewin->show() in the constructor and enable the pb.show() as below in the application test, the widget doesn't display.
void TestRig::TestProgress( void )
{
ProgressBar pb( this );
pb.SetWindowTitle( "Progress bar title" );
// pb.show();
xvt_dm_post_note( "Test Progress: Any Key To Continue" );
}
What am I missing here. Should not the pb.show() in the application cause the widget to display.
The reason I need this behavior is that there are other items that have to be setup before the pb widget is displayed. Other controls may or may not be inserted and the geometry needs to be adjusted prior to the actual display.
Thanks