[Interest] Qml MessageDialog not centered over window

Murphy, Sean smurphy at walbro.com
Mon Sep 25 14:57:25 CEST 2017

> 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.

Ok. I still need to figure out what I'm doing wrong in my application that I'm 
not able to use a QGuiApplication without getting that assert for some reason.
I really would like it to be a MessageDialog, not a QMessageBox, but as I've got
things right now, I can't seem to get QGuiApplication to work.

My application is pretty lightweight, and it is based off from the Qt Quick Extras -
Dashboard in the examples folder. That example runs just fine using QGuiApplication,
so I don't get what I've done to it that makes it assert now. I guess I need to start 
from the working example and begin adding in chunks of my actual application until
I find out what the problems is.


More information about the Interest mailing list