src/gui/image/qpixmap.cpp
changeset 30 5dc02b23752f
parent 19 fcece45ef507
child 33 3e2da88830cd
equal deleted inserted replaced
29:b72c6db6890b 30:5dc02b23752f
  1069         return QPixmap();
  1069         return QPixmap();
  1070 
  1070 
  1071     if (widget->testAttribute(Qt::WA_PendingResizeEvent) || !widget->testAttribute(Qt::WA_WState_Created))
  1071     if (widget->testAttribute(Qt::WA_PendingResizeEvent) || !widget->testAttribute(Qt::WA_WState_Created))
  1072         sendResizeEvents(widget);
  1072         sendResizeEvents(widget);
  1073 
  1073 
       
  1074     widget->d_func()->prepareToRender(QRegion(),
       
  1075         QWidget::DrawWindowBackground | QWidget::DrawChildren | QWidget::IgnoreMask);
       
  1076 
  1074     QRect r(rect);
  1077     QRect r(rect);
  1075     if (r.width() < 0)
  1078     if (r.width() < 0)
  1076         r.setWidth(widget->width() - rect.x());
  1079         r.setWidth(widget->width() - rect.x());
  1077     if (r.height() < 0)
  1080     if (r.height() < 0)
  1078         r.setHeight(widget->height() - rect.y());
  1081         r.setHeight(widget->height() - rect.y());
  1079 
  1082 
  1080     if (!r.intersects(widget->rect()))
  1083     if (!r.intersects(widget->rect()))
  1081         return QPixmap();
  1084         return QPixmap();
  1082 
  1085 
  1083     QPixmap res(r.size());
  1086     QPixmap res(r.size());
  1084     widget->render(&res, QPoint(), r,
  1087     widget->d_func()->render(&res, QPoint(), r, QWidget::DrawWindowBackground
  1085                    QWidget::DrawWindowBackground | QWidget::DrawChildren | QWidget::IgnoreMask);
  1088                              | QWidget::DrawChildren | QWidget::IgnoreMask, true);
  1086     return res;
  1089     return res;
  1087 }
  1090 }
  1088 
  1091 
  1089 /*!
  1092 /*!
  1090     \fn QPixmap QPixmap::grabWidget(QWidget *widget, int x, int y, int
  1093     \fn QPixmap QPixmap::grabWidget(QWidget *widget, int x, int y, int
  1361 
  1364 
  1362     Use the toImage() function instead.
  1365     Use the toImage() function instead.
  1363 */
  1366 */
  1364 
  1367 
  1365 /*!
  1368 /*!
  1366     \fn bool QPixmap::convertFromImage(const QImage &image, Qt::ImageConversionFlags flags)
  1369     Replaces this pixmap's data with the given \a image using the
  1367 
  1370     specified \a flags to control the conversion.  The \a flags
  1368     Use the static fromImage() function instead.
  1371     argument is a bitwise-OR of the \l{Qt::ImageConversionFlags}.
  1369 */
  1372     Passing 0 for \a flags sets all the default options. Returns true
       
  1373     if the result is that this pixmap is not null.
       
  1374 
       
  1375     Note: this function was part of Qt 3 support in Qt 4.6 and earlier.
       
  1376     It has been promoted to official API status in 4.7 to support updating
       
  1377     the pixmap's image without creating a new QPixmap as fromImage() would.
       
  1378 
       
  1379     \sa fromImage()
       
  1380     \since 4.7
       
  1381 */
       
  1382 bool QPixmap::convertFromImage(const QImage &image, Qt::ImageConversionFlags flags)
       
  1383 {
       
  1384     if (image.isNull() || !data)
       
  1385         *this = QPixmap::fromImage(image, flags);
       
  1386     else
       
  1387         data->fromImage(image, flags);
       
  1388     return !isNull();
       
  1389 }
  1370 
  1390 
  1371 /*!
  1391 /*!
  1372     \fn QPixmap QPixmap::xForm(const QMatrix &matrix) const
  1392     \fn QPixmap QPixmap::xForm(const QMatrix &matrix) const
  1373 
  1393 
  1374     Use transformed() instead.
  1394     Use transformed() instead.