Posted on 2011-04-29 23:02
RTY 阅读(713)
评论(0) 编辑 收藏 引用 所属分类:
Qt 、
Python
1. 示例代码
1 self.screenshotLabel.setPixmap(self.originalPixmap.scaled(
2 self.screenshotLabel.size(), QtCore.Qt.KeepAspectRatio,
3 QtCore.Qt.SmoothTransformation))
2. Label 的 setPixmap函数说明
This property holds the label's pixmap.
If no pixmap has been set this will return 0.
Setting the pixmap clears any previous content. The buddy shortcut, if any, is disabled.
Access functions:
const QPixmap * |
pixmap () const |
void |
setPixmap ( const QPixmap & ) |
3. 对QPixmap的scaled函数的解析
QPixmap QPixmap::scaled ( const QSize & size, Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio, Qt::TransformationModetransformMode = Qt::FastTransformation ) const
Scales the pixmap to the given size, using the aspect ratio and transformation modes specified by aspectRatioMode and transformMode.
- If aspectRatioMode is Qt::IgnoreAspectRatio, the pixmap is scaled to size.
- If aspectRatioMode is Qt::KeepAspectRatio, the pixmap is scaled to a rectangle as large as possible inside size, preserving the aspect ratio.
- If aspectRatioMode is Qt::KeepAspectRatioByExpanding, the pixmap is scaled to a rectangle as small as possible outside size, preserving the aspect ratio.
If the given size is empty, this function returns a null pixmap.
In some cases it can be more beneficial to draw the pixmap to a painter with a scale set rather than scaling the pixmap. This is the case when the painter is for instance based on OpenGL or when the scale factor changes rapidly.
See also isNull() and Pixmap Transformations.
QPixmap QPixmap::scaled ( int width, int height, Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio, Qt::TransformationModetransformMode = Qt::FastTransformation ) const
This is an overloaded function.
Returns a copy of the pixmap scaled to a rectangle with the given width and height according to the given aspectRatioMode and transformMode.
If either the width or the height is zero or negative, this function returns a null pixmap.