PDA

View Full Version : QGraphicsScene infinite update



danics
8th December 2015, 09:03
Hi every body!

I have 2 viewports each one has a different qgraphicscene and each viewport has a ItemView class for generating QGraphicsItem from my custom model like this



myviewport::myviewport(QWidget* parent) ...
{
myscene = new MyScene(this);
setScene(myscene);

viewWrapper = new MyItemView(this);
}

MainWindow::MainWindow()
{
mainView = new myviewport(this);
subView = new myviewport(this);

myModel = new MyModel(this);
mainView->setModel(myModel);
subView->setModel(myModel);
}


when I hide subView everything works great, if I change model from different tablewidget, my graphics item change too without any problem. but each time I show subView, subView has the Items too but qgraphicsscene go to infinite loop of updating (i have a breakpoint in drawBackground function of myscene and its call every time),

however if I haven't any qgraphicsitem in my viewwrapper, everythings works good when two views are visible.

its really strange behavior for me, the viewwrapper doesn't get any signal, model don't change at all just change the visiblity of subView to show and my viewports freeze, Other widgets work yet.

So witch functions of a qgraphicsitem can cause of updating a whole scene?

when i trace item creation in model, each viewwrapper create a QGraphicsItem for parent scene correctly, after this I correctly didn't get any signal of dataChanged or reset model too.

the code is complicated and big so i described what i did in my program thanks in advance.

danics
8th December 2015, 12:09
I found the problem, I call prepareGeometryChange() of some items in drawbackground() function of myscene, but yet I didn't understand why this is a problem in two view but not in one view. however i think my program has some important bugs yet.