How to place a GraphicsView in a layout object
I need to create a scene and place it in a GraphicsView. Once I finish the scene and place it in the GraphicsView, how do I place the GraphicsView inside a layout object? My layout object is called vlayout and is an instance of QVBoxLayout. This is what I have so far (mostly from online examples):
- QGraphicsScene scene;
- scene.addText("Hello, world!");
- view.show();
- //Here I want to place the view inside a layout object called vlayout
6 replies
- vlayout->addWidget(view);
Syntactically, everything is fine, but I can’t get my image to show up. This is what I have:
- QGraphicsScene scene;
- view.show();
- vlayout->addWidget(&view);
The QPushButton shows up fine in the layout, but not the view. Any idea what I am doing wrong?
You must log in to post a reply. Not a member yet? Register here!

