Please see code below. I've got an 842 x595 image and I want to split it into two images of size 421x595 each, hence I used the copy function. The copying works perfect and I am able the display the first copy of my Image in the view. Please see the attached image and the output to my program.background1.jpgOutput_screen1.jpg
{
painter->setBrush(Qt::NoBrush);
QImage frontPageBackground
= image.
copy(QRect(422,
0,image.
rect().
width(),image.
rect().
height()));
QImage backPageBackground
= image.
copy(QRect(0,
0,image.
rect().
width()/2, image.
rect().
height()));
painter->drawImage(rect, backPageBackground );
}
void Page::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
painter->setBrush(Qt::NoBrush);
QImage image(directory);
QImage frontPageBackground = image.copy(QRect(422,0,image.rect().width(),image.rect().height()));
QImage backPageBackground = image.copy(QRect(0,0,image.rect().width()/2, image.rect().height()));
painter->drawImage(rect, backPageBackground );
}
To copy to clipboard, switch view to plain text mode
The problem comes when I want to display the second piece of the image and suddenly my scene looks like this.Output_screen2.jpg Please help guys. I know this is a minor problem but I just don't get why this is happening.
Bookmarks