Wie auf center einem QDialog in QT?

Habe ich in diesem Beispiel-code:

QDialog *dialog = new QDialog(this);
QPoint dialogPos = dialog->mapToGlobal(dialog->pos());
QPoint thisPos = mapToGlobal(this->pos());
dialog->exec();

Aber der Dialog ist nicht zentriert auf seine Eltern. Vielen Dank im Voraus.

UPDATE:

Ich rufe den Dialog von Konstruktor von 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();

}

Aber ich bekomme ist:

Wie auf center einem QDialog in QT?

InformationsquelleAutor Omar Murcia | 2017-02-19
Schreibe einen Kommentar