Have someone any idea, dealing with the resizing of a QGraphicsPixmapItem???
Reading the documentation i find many reasons that could introduce problem during the resize:
1)When we resize a QGraphicsRectItem, we work on a QrectF that is more accurate to give us the corners coordinate(QGraphicsPixmapItem work with QRect Object)
2)QGraphicsPixmapItem objects, start drawing its pixmap, starting from the QpointF "offset()", which defines the top-left corner of the pixmap; so i think that if we change the rect of the pixmap, we have to change also the offset() of the current resizing item.
I make a lot of different version of resizing, but i can't find the solution.
I find the right resizing method for the bottom side and the bottom right corner(So i think the problem starts when we modify the top-left corner!!!)
Bottom-side:
QRect new_rect
(pixmap
().
rect().
topLeft(),
QPoint(pixmap
().
rect().
topRight().
x(),event
->pos
().
toPoint().
y()));
setPixmap
(QPixmap::fromImage(image.
scaled(QSize(new_rect.
width(),new_rect.
height()),Qt
::IgnoreAspectRatio,Qt
::FastTransformation)));
QRect new_rect(pixmap().rect().topLeft(),
QPoint(pixmap().rect().topRight().x(),event->pos().toPoint().y()));
setPixmap(QPixmap::fromImage(image.scaled(QSize(new_rect.width(),new_rect.height()),Qt::IgnoreAspectRatio,Qt::FastTransformation)));
To copy to clipboard, switch view to plain text mode
Botto-right corner:
QRect new_rect
(pixmap
().
rect().
topLeft(),
QPoint(event
->pos
().
toPoint().
x(),
event->pos().toPoint().y()));
setPixmap
(QPixmap::fromImage(image.
scaled(QSize(new_rect.
width(),new_rect.
height()),Qt
::IgnoreAspectRatio,Qt
::FastTransformation)));
QRect new_rect(pixmap().rect().topLeft(),QPoint(event->pos().toPoint().x(),
event->pos().toPoint().y()));
setPixmap(QPixmap::fromImage(image.scaled(QSize(new_rect.width(),new_rect.height()),Qt::IgnoreAspectRatio,Qt::FastTransformation)));
To copy to clipboard, switch view to plain text mode
I hope someone will help me.........thanks a lot.
Bookmarks