budda
1st August 2010, 23:45
my question is general in respects to a program I am working on. I got into the habit of making multiple QGraphicsViews in a single program, with the form in the mainwindow.ui and then I use QGraphicsScene along with them. Usually this is because of a 3d text animation or some other such sprite. Which is usually stationary. Is having smaller multiple views not efficient on memory? Compared to one large GraphicsView? My game I have going now, is running 4 different ones, and apparently it just started crashing after adding the 4th one. The pics themselves donot exceed the 10mg pixmap cache at all, but it is still crashing. Just wondering if I could get any tips on this. And some tidbits about scene magement would be useful. I'm not too certain about refreshing a scene, and think that I am wastefully reinitializing the whole thing over and over again.
for instance this method function is being called from a eventTimer method function and produces a spinning graphics through all of the pics. ( there is a pause on how often it this is repeatedly called and spinCount is a global int that is incremented during the timed animation)
void MainWindow::title()
{
ui->graphicsView_2->setSceneRect(0, 0, 274, 92);
titleScene.setSceneRect(0, 0, 274, 92);
titleScene.clear();
static const char * SP[] =
{ ":/pics/spin/title00.gif", ":/pics/spin/title01.gif", ":/pics/spin/title02.gif", ":/pics/spin/title03.gif",
":/pics/spin/title04.gif", ":/pics/spin/title05.gif", ":/pics/spin/title06.gif", ":/pics/spin/title07.gif",
":/pics/spin/title08.gif", ":/pics/spin/title09.gif", ":/pics/spin/title10.gif", ":/pics/spin/title11.gif",
":/pics/spin/title12.gif", ":/pics/spin/title13.gif", ":/pics/spin/title14.gif", ":/pics/spin/title15.gif",
":/pics/spin/title16.gif", ":/pics/spin/title17.gif", ":/pics/spin/title18.gif", ":/pics/spin/title19.gif" };
QPixmap s(SP[spinCount]);
titleScene.addPixmap(s);
ui->graphicsView_2->setScene(& titleScene);
}
for instance this method function is being called from a eventTimer method function and produces a spinning graphics through all of the pics. ( there is a pause on how often it this is repeatedly called and spinCount is a global int that is incremented during the timed animation)
void MainWindow::title()
{
ui->graphicsView_2->setSceneRect(0, 0, 274, 92);
titleScene.setSceneRect(0, 0, 274, 92);
titleScene.clear();
static const char * SP[] =
{ ":/pics/spin/title00.gif", ":/pics/spin/title01.gif", ":/pics/spin/title02.gif", ":/pics/spin/title03.gif",
":/pics/spin/title04.gif", ":/pics/spin/title05.gif", ":/pics/spin/title06.gif", ":/pics/spin/title07.gif",
":/pics/spin/title08.gif", ":/pics/spin/title09.gif", ":/pics/spin/title10.gif", ":/pics/spin/title11.gif",
":/pics/spin/title12.gif", ":/pics/spin/title13.gif", ":/pics/spin/title14.gif", ":/pics/spin/title15.gif",
":/pics/spin/title16.gif", ":/pics/spin/title17.gif", ":/pics/spin/title18.gif", ":/pics/spin/title19.gif" };
QPixmap s(SP[spinCount]);
titleScene.addPixmap(s);
ui->graphicsView_2->setScene(& titleScene);
}