Retrieve QPlatformScreen from top level when querying widget metrics.

Check for 0 and use primary screen as default.

Change-Id: Ib4d0d3f507e7fb17687f5e126b49f98cfdbead6c
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Reviewed-on: http://codereview.qt.nokia.com/2166
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
bb10
Friedemann Kleint 2011-07-26 10:30:56 +02:00
parent 97c659a5aa
commit 32cec9f3ba
1 changed files with 9 additions and 1 deletions

View File

@ -53,6 +53,8 @@
#include "QtGui/private/qwindow_p.h"
#include <QtGui/QPlatformCursor>
#include <QtGui/QGuiApplication>
#include <QtGui/QScreen>
QT_BEGIN_NAMESPACE
@ -733,7 +735,13 @@ int QWidget::metric(PaintDeviceMetric m) const
{
Q_D(const QWidget);
QPlatformScreen *screen = QPlatformScreen::platformScreenForWindow(windowHandle());
QPlatformScreen *screen = 0;
if (QWidget *topLevel = window())
if (QWindow *topLevelWindow = topLevel->windowHandle())
screen = QPlatformScreen::platformScreenForWindow(topLevelWindow);
if (!screen && QGuiApplication::primaryScreen())
screen = QGuiApplication::primaryScreen()->handle();
if (!screen) {
if (m == PdmDpiX || m == PdmDpiY)
return 72;