src/gui/image/qpixmap.cpp
changeset 30 5dc02b23752f
parent 19 fcece45ef507
child 33 3e2da88830cd
--- a/src/gui/image/qpixmap.cpp	Wed Jun 23 19:07:03 2010 +0300
+++ b/src/gui/image/qpixmap.cpp	Tue Jul 06 15:10:48 2010 +0300
@@ -1071,6 +1071,9 @@
     if (widget->testAttribute(Qt::WA_PendingResizeEvent) || !widget->testAttribute(Qt::WA_WState_Created))
         sendResizeEvents(widget);
 
+    widget->d_func()->prepareToRender(QRegion(),
+        QWidget::DrawWindowBackground | QWidget::DrawChildren | QWidget::IgnoreMask);
+
     QRect r(rect);
     if (r.width() < 0)
         r.setWidth(widget->width() - rect.x());
@@ -1081,8 +1084,8 @@
         return QPixmap();
 
     QPixmap res(r.size());
-    widget->render(&res, QPoint(), r,
-                   QWidget::DrawWindowBackground | QWidget::DrawChildren | QWidget::IgnoreMask);
+    widget->d_func()->render(&res, QPoint(), r, QWidget::DrawWindowBackground
+                             | QWidget::DrawChildren | QWidget::IgnoreMask, true);
     return res;
 }
 
@@ -1363,10 +1366,27 @@
 */
 
 /*!
-    \fn bool QPixmap::convertFromImage(const QImage &image, Qt::ImageConversionFlags flags)
+    Replaces this pixmap's data with the given \a image using the
+    specified \a flags to control the conversion.  The \a flags
+    argument is a bitwise-OR of the \l{Qt::ImageConversionFlags}.
+    Passing 0 for \a flags sets all the default options. Returns true
+    if the result is that this pixmap is not null.
+
+    Note: this function was part of Qt 3 support in Qt 4.6 and earlier.
+    It has been promoted to official API status in 4.7 to support updating
+    the pixmap's image without creating a new QPixmap as fromImage() would.
 
-    Use the static fromImage() function instead.
+    \sa fromImage()
+    \since 4.7
 */
+bool QPixmap::convertFromImage(const QImage &image, Qt::ImageConversionFlags flags)
+{
+    if (image.isNull() || !data)
+        *this = QPixmap::fromImage(image, flags);
+    else
+        data->fromImage(image, flags);
+    return !isNull();
+}
 
 /*!
     \fn QPixmap QPixmap::xForm(const QMatrix &matrix) const