如何删除QPixmap周围的额外边距? [英] how to remove extra margins arounding a QPixmap?

查看:118
本文介绍了如何删除QPixmap周围的额外边距?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的类的paint函数中绘制了一个QRectF,并将QPixmap设置为它的画笔。我从包含此QRectF的类构建一个对象。当我将这个项目放在我的场景中并为场景设置背景时,会出现QRectF。我添加到场景中的QPixmap也会出现这种情况。我该怎么做才能消除额外的保证金?



I draw a QRectF in the paint function of my class and set a QPixmap as brush for it. I build an object from a class containing this QRectF. When I put this item in my scene and set background for the scene the QRectF appears. It also occurs for a QPixmap that I add to the scene. What can I do to remove the extra margins?

<pre
void MyQgraphicsObject::paint(QPainter *painter, )
{
    QRectF rec(0,0,50,60);
    QPixmap pi(":picture/im/super.jpg");
    pi=pi.scaled(50,60);
    painter->setBrush(QBrush(pi));
    painter->setPen(Qt::NoPen);
    painter->drawRoundedRect(rec,10,10);
}
////////////////////
QPixmap a(":picture/im/cloud.jpg");
scene->addPixmap(a);
scene->setbackground(Qt::blue);

推荐答案

这篇关于如何删除QPixmap周围的额外边距?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆