ayanda83
5th April 2015, 00:50
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.1105711058
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 );
}
The problem comes when I want to display the second piece of the image and suddenly my scene looks like this.11059 Please help guys. I know this is a minor problem but I just don't get why this is happening.
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 );
}
The problem comes when I want to display the second piece of the image and suddenly my scene looks like this.11059 Please help guys. I know this is a minor problem but I just don't get why this is happening.