나는이 예제 코드가 있습니다QT에서 QDialog를 중앙에 배치하는 방법?
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-the-parent-widget –
[부모 위젯에 QWidget (또는 QDialog)를 중앙에서 유지하는 방법?] (http://stackoverflow.com/questions/18385916/how-to- keep-a-qwidget-or-qdialog-centered-the-parent-widget) –