Monday, 15 March 2010

c++ - Qt: issue with QGraphicscene to show an imge -



c++ - Qt: issue with QGraphicscene to show an imge -

i trying develop simple image viewer using qt. using next code show image on qgraphicsscene widget:

qimage image(filename); firstpicture = new qgraphicsscene(); firstpicture->addpixmap(qpixmap::fromimage(image)); ui->graphicsview->setscene(firstpicture); ui->graphicsview->fitinview(firstpicture->scenerect() ,qt::keepaspectratio);

i getting next output:

how can fit image graphicsscene?

this approach works when view showed scene. in case did not phone call show(). solution:

use approach when scene shown.

you can reimplement showevent , utilize approach here.

you can scale image , set scaled image scene.

also can seek use: qt::ignoreaspectratio instead of qt::keepaspectratio.

c++ qt qgraphicsscene qimage

No comments:

Post a Comment