budda
21st June 2014, 21:49
I've got a QGraphicsView with a QGraphicsScene. In Qt5.2.0 MinGW
And I'm adding custom GraphicsViewItems to said scene.
This works just fine. But after awhile the scene clears itself.
is this normal? is there an automatic clear scene after so long?
void MainWindow::drawThisView()
{
thisView->setSceneRect(0,0,690,242);
thisView->setCacheMode(QGraphicsView::CacheBackground);
thisView->setViewportUpdateMode(QGraphicsView::BoundingRectV iewportUpdate);
thisScene.setItemIndexMethod(QGraphicsScene::NoInd ex);
thisView->setFrameStyle(0);
thisView->setAlignment(Qt::AlignLeft);
thisView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOf f);
thisView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff) ;
thisView->setStyleSheet(QString(" background-color: transparent; border-color: transparent; background: url(:/pics/thisSceneBkgr.png);"));
thisScene.setSceneRect(0,0,690,242);
thisScene.clear();
CustGrItem *tempDraw = new CustGrItem(225, 0, -1, -1); //sets the 225 item, set color to black, set x, set y
thisScene.addItem(tempDraw);
tempDraw->setPos(100,32);
thisView->setScene(& thisScene);
thisView->show();
}
And I'm adding custom GraphicsViewItems to said scene.
This works just fine. But after awhile the scene clears itself.
is this normal? is there an automatic clear scene after so long?
void MainWindow::drawThisView()
{
thisView->setSceneRect(0,0,690,242);
thisView->setCacheMode(QGraphicsView::CacheBackground);
thisView->setViewportUpdateMode(QGraphicsView::BoundingRectV iewportUpdate);
thisScene.setItemIndexMethod(QGraphicsScene::NoInd ex);
thisView->setFrameStyle(0);
thisView->setAlignment(Qt::AlignLeft);
thisView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOf f);
thisView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff) ;
thisView->setStyleSheet(QString(" background-color: transparent; border-color: transparent; background: url(:/pics/thisSceneBkgr.png);"));
thisScene.setSceneRect(0,0,690,242);
thisScene.clear();
CustGrItem *tempDraw = new CustGrItem(225, 0, -1, -1); //sets the 225 item, set color to black, set x, set y
thisScene.addItem(tempDraw);
tempDraw->setPos(100,32);
thisView->setScene(& thisScene);
thisView->show();
}