From a09c20f19b92fd4d88ee2ce487aa99322fcce20a Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 25 May 2012 15:51:39 +0200 Subject: [PATCH] QWidget::grab: Add a default value for the QRect parameter. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The documentation is misleading in that a default-constructed rectangle that has size = 0 causes the entire widget to be painted; this happens only if the one of the size values is < 0. Add a default value such that size < 0 and the entire widget is painted based on the rationale that a size = 0 might be the result of some calculation and it would be unexpected to get a pixmap containing the entire widget in that case. Change-Id: I2a5fb38cd407b4b64348213101d8196b2c40ad9a Reviewed-by: Samuel Rødal --- src/widgets/kernel/qwidget.cpp | 6 ++---- src/widgets/kernel/qwidget.h | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 3d0ffd9..355ef5b 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -4765,10 +4765,8 @@ static void sendResizeEvents(QWidget *target) given \a rectangle. If the \a widget has any children, then they are also painted in the appropriate positions. - If no rectangle is specified (the default) the entire widget is - painted. - - Replacement for Qt 4's QPixmap::grabWidget(). + If a rectangle with an invalid size is specified (the default), + the entire widget is painted. \sa render(), QPixmap */ diff --git a/src/widgets/kernel/qwidget.h b/src/widgets/kernel/qwidget.h index b7a5e26..0110a38 100644 --- a/src/widgets/kernel/qwidget.h +++ b/src/widgets/kernel/qwidget.h @@ -351,7 +351,7 @@ public: const QRegion &sourceRegion = QRegion(), RenderFlags renderFlags = RenderFlags(DrawWindowBackground | DrawChildren)); - Q_INVOKABLE QPixmap grab(const QRect &rectangle); + Q_INVOKABLE QPixmap grab(const QRect &rectangle = QRect(QPoint(0, 0), QSize(-1, -1))); #ifndef QT_NO_GRAPHICSEFFECT QGraphicsEffect *graphicsEffect() const; -- 2.7.4