PDA

View Full Version : Possible QGraphicsView/Scene bug



Corran
30th December 2006, 00:21
Hey all,
I think I might have found a bug in Qt4 but of course it's always possible that I've just done something wrong.

I you could have a look at the attached sources and first let me know if you encounter the same thing as me:

Clicking in the area will draw dots (the view will move around to centre on the dots)
Click "New" to create a new GameBoardScene
Clicking in the area no longer works the same:
The dots are added to the Scene but, for some reason, the View isn't updated unless you:
* Resize the window
* Probably some other things which force a refresh

And if you do encounter the same bug, is there anything in my code that is blatantly wrong?

Many thanks,
Matt Williams

wysota
30th December 2006, 01:47
I've changed your code a little and now it works fine:

void KSquares::gameNew()
{
QGraphicsScene *sc = m_scene; // store old scene
m_scene = new GameBoardScene(); // create new scene
m_view->setScene(m_scene); // set new scene
delete sc; // delete old scene
}

This way the graphics view always has a valid scene.