layout - qt get scrollview position -
i have qgraphicsview inside horizontal layout. qgraphicsscene contained in qgraphics scene pretty large (thousands of pixels), scroll bars show default allow me scroll through view.
every time update scene inside graphics scene, delete old scene, make new one, populate objects, , call view->setscene(scene). when this, however, scroll bars default top left corner of qgraphicsview, instead of staying at.
i tried saving qgraphicsscene::scenerect before destroying scene, doing setscenerect() afterwards restore it, doesn't work since affects scene itself, not qgraphicsview that's displaying it. tried view->verticalscrollbar()->setvalue(), doesn't appear affect scroll bars @ all.
how can access scroll bars created me default, , set them value stored earlier?
fixed not deleting previous scene until after new 1 set.
e.g.
qgraphicsscene *previousscene = scene; scene = new qgraphicsscene(0, 0, levelplist.value("level_width").toint(), levelplist.value("level_height").toint()); // config scene qgraphicsview *view = ui->graphicsview; view->setscene(scene); delete previousscene;
Comments
Post a Comment