how to remove extra margins arounding a QPixmap?

坚强是说给别人听的谎言 提交于 2019-12-10 10:29:13

问题


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?

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);

来源:https://stackoverflow.com/questions/24475305/how-to-remove-extra-margins-arounding-a-qpixmap

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!