diff options
author | Prasanth Ullattil <prasanth.ullattil@nokia.com> | 2010-02-26 13:37:59 (GMT) |
---|---|---|
committer | Prasanth Ullattil <prasanth.ullattil@nokia.com> | 2010-02-26 13:40:51 (GMT) |
commit | 9229489304894e35e137606ea263f007e5605d22 (patch) | |
tree | 7dc2a77ae667bddded53980ba25563bb31f02510 | |
parent | f53f18d442629b859dd68ffbc2bae0ec104a9bd2 (diff) | |
download | Qt-9229489304894e35e137606ea263f007e5605d22.zip Qt-9229489304894e35e137606ea263f007e5605d22.tar.gz Qt-9229489304894e35e137606ea263f007e5605d22.tar.bz2 |
Fixed autotest tst_QWidget::translucentWidget() on Windows Vista & above
Grabbing layered windows doesn't work on Vista and above, so instead we
need to grab the corresponding area of the desktop widget.
Reviewed-by: Samuel
-rw-r--r-- | src/gui/image/qpixmap.cpp | 6 | ||||
-rw-r--r-- | tests/auto/qwidget/tst_qwidget.cpp | 10 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index 1df7946..08003e5 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -2026,12 +2026,16 @@ QPixmap QPixmap::fromImage(const QImage &image, Qt::ImageConversionFlags flags) over the one you grab, you get pixels from the overlying window, too. The mouse cursor is generally not grabbed. - Note on X11that if the given \a window doesn't have the same depth + Note on X11 that if the given \a window doesn't have the same depth as the root window, and another window partially or entirely obscures the one you grab, you will \e not get pixels from the overlying window. The contents of the obscured areas in the pixmap will be undefined and uninitialized. + On Windows Vista and above grabbing a layered window, which is + created by setting the Qt::WA_TranslucentBackground attribute, will + not work. Instead grabbing the desktop widget should work. + \warning In general, grabbing an area outside the screen is not safe. This depends on the underlying window system. diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index b59017b..abd9604 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -8829,7 +8829,15 @@ void tst_QWidget::translucentWidget() #endif QTest::qWait(200); - QPixmap widgetSnapshot = QPixmap::grabWindow(label.winId()); + QPixmap widgetSnapshot; + +#ifdef Q_WS_WIN + QWidget *desktopWidget = QApplication::desktop()->screen(0); + if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) + widgetSnapshot = QPixmap::grabWindow(desktopWidget->winId(), 0,0, label.width(), label.height()); + else +#endif + widgetSnapshot = QPixmap::grabWindow(label.winId()); QImage actual = widgetSnapshot.toImage().convertToFormat(QImage::Format_RGB32); QImage expected = pm.toImage().convertToFormat(QImage::Format_RGB32); QCOMPARE(actual.size(),expected.size()); |