У меня есть этот пример код:Как центрировать QDialog в QT?
QDialog *dialog = new QDialog(this);
QPoint dialogPos = dialog->mapToGlobal(dialog->pos());
QPoint thisPos = mapToGlobal(this->pos());
dialog->exec();
Но диалог не сосредоточен на его родителях. Заранее спасибо.
UPDATE:
Я звоню Диалог из конструктора в MainWindow:
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
{
this->panelInferior = new WidgetTabsInferior;
this->acciones = new Acciones(this);
crearAcciones();
crearBarraMenu();
crearToolbar();
crearTabsEditor();
crearArbolDir();
crearDockWindows();
crearStatusBar();
setWindowIcon(QIcon(":imgs/logo.png"));
connect(this->pestanasEditor , SIGNAL(currentChanged(int)),this,SLOT(cambioTab(int)));
this->dialogo = new AcercaDe(this);
this->dialogo->move(x() + (width() - dialogo->width())/2,
y() + (height() - dialogo->height())/2);
this->dialogo->show();
this->dialogo->raise();
this->dialogo->activateWindow();
}
Но я получаю:
http://www.qtcentre.org/threads/43802-Centering-child-window-in-parent http://stackoverflow.com/questions/18385916/how-to-keep-a-qwidget-or -qdialog-centered-to-its-parent-widget –
Возможный дубликат [Как сохранить QWidget (или QDialog) в центре его родительского виджета?] (http://stackoverflow.com/questions/18385916/how-to- keep-a-qwidget-or-qdialog-center-to-its-parent-widget) –