[英]QML Dialog positioning in ApplicationWindow
I am finding it impossible to position a Dialog central to my ApplicationWindow in QT 5.12我发现在 QT 5.12 中无法将 Dialog 定位到我的 ApplicationWindow 的中心
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使用 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.我试过添加一个固定的 z 位置,但似乎没有任何东西将 Dialog 向下移动到窗口中。 I've tried MainWindowMessageDialog on its own outside of an Item.我已经在项目之外单独尝试过 MainWindowMessageDialog 。 Nothing seems to shift it?好像没什么变化吧? Am I missing something?我错过了什么吗?
This turned out to be an issue of modality.结果证明这是一个模态问题。
https://bugreports.qt.io/browse/QTBUG-82737?jql=text%20~%20%22MessageDialog%22 https://bugreports.qt.io/browse/QTBUG-82737?jql=text%20~%20%22MessageDialog%22
Adding添加
modality: Qt.ApplicationModal
Did the trick成功了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.