PDA

View Full Version : Issues with QGraphicsView show() called from function other than main()



dpatel
15th July 2010, 08:50
Hi,

I am using QGraphicsView (which has QGraphicsScene containing the widgets) for my UI. In main() I create QGraphicsView object and set the scene and add widgets to it. Then I call show() on QGraphicsView. This setup works fine.
Now I move the QGrahicsView and related setup to a separate class and expose a function loadUI() which will be called from the main() to load the UI. When I call loadUI(), the UI come for a fraction of section and then goes away. The application is still running but no UI.

What is wrong with my new setup?

Thanks.

SixDegrees
15th July 2010, 09:16
Sounds like you're creating your QGraphicsScene in your class function. Once the function terminates, local variables are destroyed, along with your scene.

Code would be helpful.

dpatel
15th July 2010, 10:00
Ahh very basic principle of object lifetime. Thanks for pointing that out. I verified, and that was the only issue.