summaryrefslogtreecommitdiffstats
path: root/src/widgets/dialogs/qdialog.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/widgets/dialogs/qdialog.cpp')
-rw-r--r--src/widgets/dialogs/qdialog.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp
index 52976611aa..c416ba9a5c 100644
--- a/src/widgets/dialogs/qdialog.cpp
+++ b/src/widgets/dialogs/qdialog.cpp
@@ -871,17 +871,25 @@ void QDialog::showEvent(QShowEvent *event)
/*! \internal */
void QDialog::adjustPosition(QWidget* w)
{
+ Q_D(QDialog);
+
if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
if (theme->themeHint(QPlatformTheme::WindowAutoPlacement).toBool())
return;
QPoint p(0, 0);
int extraw = 0, extrah = 0;
- if (w)
+ const QWindow *parentWindow = nullptr;
+ if (w) {
w = w->window();
+ } else {
+ parentWindow = d->transientParentWindow();
+ }
QRect desk;
QScreen *scrn = nullptr;
if (w)
scrn = w->screen();
+ else if (parentWindow)
+ scrn = parentWindow->screen();
else if (QGuiApplication::primaryScreen()->virtualSiblings().size() > 1)
scrn = QGuiApplication::screenAt(QCursor::pos());
else
@@ -918,6 +926,11 @@ void QDialog::adjustPosition(QWidget* w)
pp = w->mapToGlobal(QPoint(0,0));
p = QPoint(pp.x() + w->width()/2,
pp.y() + w->height()/ 2);
+ } else if (parentWindow) {
+ // QTBUG-63406: Widget-based dialog in QML, which has no Widget parent
+ // but a transient parent window.
+ QPoint pp = parentWindow->mapToGlobal(QPoint(0, 0));
+ p = QPoint(pp.x() + parentWindow->width() / 2, pp.y() + parentWindow->height() / 2);
} else {
// p = middle of the desktop
p = QPoint(desk.x() + desk.width()/2, desk.y() + desk.height()/2);