[Interest] Qml MessageDialog not centered over window
Shawn Rutledge
Shawn.Rutledge at qt.io
Mon Sep 25 14:09:34 CEST 2017
> On 25 Sep 2017, at 13:17, Murphy, Sean <smurphy at walbro.com> wrote:
>
> And in my real main.cpp I have
> QApplication app(argc, argv);
> QQmlEngine engine;
> QQmlComponent component(&engine, QUrl("qrc:/qml/dashboard.qml"));
> component.create();
> Whereas the project that was generated by Creator when I was testing your
> example is
> QGuiApplication app(argc, argv);
> QQmlApplicationEngine engine;
> engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
Aha, it happens when using a QApplication; the MessageDialog is actually a QMessageBox in that case. I can get the same result with the test qml like this:
qml -apptype widget messagedialog.qml
(that makes the qml runtime use a QApplication instead of QGuiApplication) and maybe we have some trouble making a QWidget dialog transient for a QWindow. In QMessageBoxHelper::show(), it does try to set its transient parent:
virtual bool show(Qt::WindowFlags f, Qt::WindowModality m, QWindow *parent) {
m_dialog.winId();
QWindow *window = m_dialog.windowHandle();
Q_ASSERT(window);
window->setTransientParent(parent);
qDebug() << window << "transient for" << parent;
… }
QMessageBoxHelper::show - QWidgetWindow(0x7fcf52d80a40, name="QMessageBoxClassWindow") transient for QQuickWindowQmlImpl(0x7fcf54a192c0)
I wrote it up as QTBUG-63406.
More information about the Interest
mailing list