summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel/qwidget.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-03-14 10:49:20 +0100
committerLiang Qi <liang.qi@qt.io>2017-03-14 10:52:24 +0100
commit0c034a649f61019c16aba479fe79d20dde41f2f2 (patch)
tree54545862591044b65e618989805945bceb0b3ea5 /src/widgets/kernel/qwidget.cpp
parent2162f01111d21d0ce66ceb8be290b0a13653e691 (diff)
parentdf40b1115db600e8de1c4774476fa30956a34fd9 (diff)
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts: src/widgets/widgets/qpushbutton.cpp Change-Id: I615de00e6e64540c50f658d4d8ab3e002d701a81
Diffstat (limited to 'src/widgets/kernel/qwidget.cpp')
-rw-r--r--src/widgets/kernel/qwidget.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index 8a642940cd..8d5c3e415a 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -12769,8 +12769,6 @@ void QWidget::activateWindow()
*/
int QWidget::metric(PaintDeviceMetric m) const
{
- Q_D(const QWidget);
-
QWindow *topLevelWindow = 0;
QScreen *screen = 0;
if (QWidget *topLevel = window()) {
@@ -12798,16 +12796,16 @@ int QWidget::metric(PaintDeviceMetric m) const
} else if (m == PdmDepth) {
return screen->depth();
} else if (m == PdmDpiX) {
- if (d->extra && d->extra->customDpiX)
- return d->extra->customDpiX;
- else if (d->parent)
- return static_cast<QWidget *>(d->parent)->metric(m);
+ for (const QWidget *p = this; p; p = p->parentWidget()) {
+ if (p->d_func()->extra && p->d_func()->extra->customDpiX)
+ return p->d_func()->extra->customDpiX;
+ }
return qRound(screen->logicalDotsPerInchX());
} else if (m == PdmDpiY) {
- if (d->extra && d->extra->customDpiY)
- return d->extra->customDpiY;
- else if (d->parent)
- return static_cast<QWidget *>(d->parent)->metric(m);
+ for (const QWidget *p = this; p; p = p->parentWidget()) {
+ if (p->d_func()->extra && p->d_func()->extra->customDpiY)
+ return p->d_func()->extra->customDpiY;
+ }
return qRound(screen->logicalDotsPerInchY());
} else if (m == PdmPhysicalDpiX) {
return qRound(screen->physicalDotsPerInchX());