1

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

CitizenFish
  • 312
  • 2
  • 13
  • Weird, looks like a bug on Mac OS (can't reproduce it on Win 10). You may overcome this by using dialog from Qt Quick Controls 2 (`import QtQuick.Controls 2.5`) instead of `QtQuick.Dialogs` or `MessageDialog` from `Qt.labs.platform 1.1`. – mip Apr 02 '20 at 07:21

1 Answers1

1

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

CitizenFish
  • 312
  • 2
  • 13