Hi all,
I have set up a QGraphicsScene & QGraphicsView and added a QGraphicsPixmapItem that has a square bounding QRect. The center of the QPixmap is at the scene center.
i.e.
bg->setPos(-50,-50);
graphicsView->setScene(graphicsScene);
graphicsView->fitInView(bg);
QGraphicsView* graphicsView;
QGraphicsScene* graphicsScene = new QGraphicsScene();
QPixmap pic = QPixmap(":/new/pic.jpg").scaled(QSize(100,100));
QGraphicsPixmapItem* bg = graphicsScene->addPixmap(pic);
bg->setPos(-50,-50);
graphicsView->setScene(graphicsScene);
graphicsView->fitInView(bg);
To copy to clipboard, switch view to plain text mode
This allows the pixmap to fill the entire view so I don't see any whitespace. The problem comes when I rotate by calling rotate() on the QGraphicsView which contains pixmap;
int degrees;
graphicsView->rotate(degrees);
int degrees;
graphicsView->rotate(degrees);
To copy to clipboard, switch view to plain text mode
Where degrees is some value I get from the user.
The view rotates as I would expect, creating a "diamond" from the rotated square QPixmap. What I would like to do now is to make a square again by essentially taking the inset square of the image, and filling the graphicsScene with that new image.
I appreciate any ideas anyone has for how to do this.
Thank you.
Bookmarks