Hello,
dlg.show();
QDialog dlg( this );
dlg.show();
To copy to clipboard, switch view to plain text mode
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:
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 );
}
}
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 );
}
}
To copy to clipboard, switch view to plain text mode
There are other ways?
Bookmarks