qtdialogqmlqt-quickapplicationwindow

QML Dialog positioning in ApplicationWindow


I am finding it impossible to position a Dialog central to my ApplicationWindow in QT 5.12

import QtQuick 2.7
import QtQuick.Controls 2.2
import QtQuick.Dialogs 1.2


ApplicationWindow {

    id:mainApplicationWindow
    visible: true
    height: 500
    width: 500


  Item {
      anchors.centerIn: parent
      MainWindowMessageDialog{
          id: messageDialog
      }
  }

  Component.onCompleted: {
      messageDialog.open()
  }
}

With MainWindowMessageDialog.qml

import QtQuick 2.0
import QtQuick.Dialogs 1.2

Dialog {
    title: "There seems to be a problem"
    standardButtons: StandardButton.Ok
    onAccepted: {
        this.close()
    }
}

Gives me the image below. I've tried adding a fixed z position but nothing seems to shift the Dialog downwards into the window. I've tried MainWindowMessageDialog on its own outside of an Item. Nothing seems to shift it? Am I missing something?

enter image description here


Solution

  • This turned out to be an issue of modality.

    https://bugreports.qt.io/browse/QTBUG-82737?jql=text%20~%20%22MessageDialog%22

    Adding

    modality: Qt.ApplicationModal
    

    Did the trick