[Interest] QGraphicsView stays big
Waitman Gobble
uzimac at da3m0n8t3r.com
Thu Jun 7 06:44:39 CEST 2012
Hi,
When I load an image into QGraphicsScene and add the scene to QGraphicsView, the QGraphicsView expands to image size, but if I clear and load another image which is smaller, it stays the same size.
For example, loading a 3000x2000 px image, clear, then load 150x250 px image. The QGraphicsView remains 3000x2000 px.
I suppose it could be the QGraphicsScene that stays big, but I can scroll out to 3000x2000 px.
code snippet:
/* init */
gv = new QGraphicsView(this);
gs = new QGraphicsScene(this);
QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(gv);
ui->frame_2->setLayout(layout);
gv->show();
/* load */
QPixmap pm(path);
gs->clear();
gs->addPixmap(pm);
gv->setScene(gs);
gv->update();
Any pointers or suggestions much appreciated.
Thank you,
--
Waitman Gobble
San Jose California USA
More information about the Interest
mailing list