[Qt-interest] QGraphicsView fitinView question
caius ligarius
caius9090 at gmail.com
Thu May 27 03:03:11 CEST 2010
Hi,
I am trying to fit a larger image (1024x768) in a smaller QGraphicsView
widget (100x100) using fitinview but it doesn't seem to work. The image
doesn't get scaled down instead the first 100x100 pixels of the image gets
shown in the QGraphicsView widget. Code below-
populateScene(QImage* qImage)
{
QPixmap np = fromImage(*qImage);
graphicitemView->setPixmap(np);
graphicssceneView->addItem(graphicitemView);
ui.graphicsView->fitInView(graphicssceneView->sceneRect(),Qt::IgnoreAspectRatio);
ui.graphicsView->setScene(graphicssceneView);
ui.graphicsView->show();
}
Here -
graphicitemView: is QGraphicPixmapItem
graphicssceneView: is QGraphicsScene
ui.graphicsView: is QGraphicsView
How ever very strangely the reverse works quite well with the above code i.e
- when I try to fit an image whose size is less than QGraphicsViews widget
size.
Can I use fitInView to scale down an image to fit in a smaller viewport?
Thanks,
Caius
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100526/0c660d11/attachment.html
More information about the Qt-interest-old
mailing list