jovin
10th May 2012, 21:07
Hello,
I unsure about where I should place the thread, so please move if it's in the wrong section.
So, now to my problem.
In my Qt program I have a stackedWidget and one page of the widget has a QGraphicsView in it.
Before I enter the QGraphicsView I call a function which sets up my QGraphicsScene and loads a QML file:
stackScene = new MyScene(); //inherits from QGraphicsScene
engine = new QDeclarativeEngine();
stackData = new MyData(); // contains several Vectors
engine->rootContext()->setContextProperty("stackData", stackData);
QDeclarativeComponent component(engine, QUrl(QString::fromUtf8("qrc:QML/stackSceneQML.qml")));
//qDebug() << component.errors() << endl;
object = qobject_cast<QGraphicsObject *>(component.create());
stackScene->addItem(object);
// process to QGraphicsView
It works fine and all and I free all memory allocated with new from above when I leave the QGraphicsView:
delete stackScene;
stackScene = NULL;
// delete engine; commented, because it gives me segmention fault...
// delete object; well same as above
delete stackData;
stackData = NULL;
Now the behaviour I can not explain:
The memory used is about 10 MB when I launch my program, entering the stackWidget with QGraphicsView
adds a few kB - but leaving it doesn't remove even one kB instead I stays and adds more kB when I switch to it again.
I stopped at 20MB...
I hope someone may have a clue about what's going wrong here.
It's really annoying.
I unsure about where I should place the thread, so please move if it's in the wrong section.
So, now to my problem.
In my Qt program I have a stackedWidget and one page of the widget has a QGraphicsView in it.
Before I enter the QGraphicsView I call a function which sets up my QGraphicsScene and loads a QML file:
stackScene = new MyScene(); //inherits from QGraphicsScene
engine = new QDeclarativeEngine();
stackData = new MyData(); // contains several Vectors
engine->rootContext()->setContextProperty("stackData", stackData);
QDeclarativeComponent component(engine, QUrl(QString::fromUtf8("qrc:QML/stackSceneQML.qml")));
//qDebug() << component.errors() << endl;
object = qobject_cast<QGraphicsObject *>(component.create());
stackScene->addItem(object);
// process to QGraphicsView
It works fine and all and I free all memory allocated with new from above when I leave the QGraphicsView:
delete stackScene;
stackScene = NULL;
// delete engine; commented, because it gives me segmention fault...
// delete object; well same as above
delete stackData;
stackData = NULL;
Now the behaviour I can not explain:
The memory used is about 10 MB when I launch my program, entering the stackWidget with QGraphicsView
adds a few kB - but leaving it doesn't remove even one kB instead I stays and adds more kB when I switch to it again.
I stopped at 20MB...
I hope someone may have a clue about what's going wrong here.
It's really annoying.