ufo-vl
27th July 2007, 06:23
Hello,
QDialog dlg( this );
dlg.show();
as result dialog window showed in random place,
can I show the dialog in main window central position?
now, for this task I use the following code:
QDialog dlg( this );
moveToCenter( &dlg );
void SMainWindow::moveToCenter( QWidget* child )
{
if ( child->parentWidget( ) )
{
QSize szParent = child->parentWidget( )->size( );
QPoint ptChild = QPoint( ( szParent.width( ) - child->size( ).width( ) ) / 2,
( szParent.height( ) - child->size( ).height( ) ) / 2 );
child->move( ptChild );
}
}
There are other ways?
QDialog dlg( this );
dlg.show();
as result dialog window showed in random place,
can I show the dialog in main window central position?
now, for this task I use the following code:
QDialog dlg( this );
moveToCenter( &dlg );
void SMainWindow::moveToCenter( QWidget* child )
{
if ( child->parentWidget( ) )
{
QSize szParent = child->parentWidget( )->size( );
QPoint ptChild = QPoint( ( szParent.width( ) - child->size( ).width( ) ) / 2,
( szParent.height( ) - child->size( ).height( ) ) / 2 );
child->move( ptChild );
}
}
There are other ways?