• 6992阅读
  • 2回复

请教QPainter中的问题 [复制链接]

上一主题 下一主题
离线michael_nuaa
 
只看楼主 正序阅读 楼主  发表于: 2009-07-17
QPainter painter;
painter.fillRect(rect, QBrush(QPixmap("Resource/picture.png")));
或painter.drawPixmap ( rect,   pixmap );

怎样才能让pixmap缩放到恰当的大小以便放入rect中呢?
离线michael_nuaa
只看该作者 2楼 发表于: 2009-07-17
非常感谢,下次我会注意的
离线dbzhang800

只看该作者 1楼 发表于: 2009-07-17
为啥不看帮助呢?

QPixmap QPixmap::scaled ( const QSize & size, Qt::AspectRatioMode aspectRatioMode = Qt::IgnoreAspectRatio, Qt::TransformationMode transformMode = 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.
快速回复
限100 字节
 
上一个 下一个