[Interest] Qml MessageDialog not centered over window
Murphy, Sean
smurphy at walbro.com
Mon Sep 25 13:17:05 CEST 2017
> Yes, it should be automatically transient for its parent. For me it works on
> Linux and macOS. So I wonder if we have a bug about this transient-
> parenting in general on Windows. Have you tried any older Qt versions?
Well, the example code you sent me worked correctly on the same version
of Qt (5.9.1) that I'm using for me real application, so I must be doing
something else wrong. First I tried your code as-is in a brand new project.
On first run, that had the main window show up centered in the monitor,
and the dialog was also centered, so I couldn't tell if the dialog was actually
being centered over its parent, or if they were both just being centered on
my screen. So I modified Window to be
Window {
visible: true
x: 60
y: 100
....
}
And that worked correctly, Window is in upper left corner of my screen,
and when the error dialog pops up it is centered over Window.
After that, I copied your Timer object into my real application and ran it.
That fails - my main Window object is off-center on my screen, the dialog is
shown centered on the screen. One thing I noticed is that the error dialogs
look different from each other, the attached images show that. The image
"testError.png" is what I get when running your sample code in its own
application. "actualError.png" is what it looks like when run from inside my
actual application, so something else is going on, but I'm not sure what yet.
Other differences I can see are my imports
import QtQuick 2.6
import QtQuick.Window 2.1
import QtQuick.Controls 2.2
import QtQuick.Controls.Styles 1.4
import QtQuick.Extras 1.4
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.3
import QtCharts 2.2
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")));
When I changed the test app to match my actual one, the incorrect behavior
returned.
I know that I changed the code in main from a QGuiApplication to a
QApplication when I started getting an assert when running
ASSERT: "!"No style available without QApplication!"" in file kernel\qapplication.cpp, line 1060
I'm not sure what I'm doing wrong to incur that assertion? Unfortunately I
can't post my entire actual code here, as it has some intellectual property in it
but if you have any ideas on what I should look for I'm open to suggestions!
The only "style" things I see in my Qml is that my application is using the
CircularGaugeStyle (https://doc.qt.io/qt-5/qml-qtquick-controls-styles-circulargaugestyle.html)
which I do need to keep in my application.
Still digging...
Sean
-------------- next part --------------
A non-text attachment was scrubbed...
Name: actualError.png
Type: image/png
Size: 8982 bytes
Desc: actualError.png
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170925/239fdf90/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testError.png
Type: image/png
Size: 14299 bytes
Desc: testError.png
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170925/239fdf90/attachment-0001.png>
More information about the Interest
mailing list