You are creating the view on the stack so it gets destroyed when the stack unwinds when the flow returns from the function. By the way I don't see the point of using a graphics scene (and view) only to add a widget to it. You can use the widget directly.