How to display a QGraphicsScene?

I've got the following code and I'm not sure how to add the QGraphicsScene to my layout..

class MainForm(QDialog):
    def __init__(self, parent=None):
        super(MainForm, self).__init__(parent)
        self.scene = QGraphicsScene(self)
        self.scene.setSceneRect(0, 0, 500, 500)
        self.view = QGraphicsView()
        zoomSlider = QSlider(Qt.Horizontal)
        zoomSlider.setRange(5, 200)
        self.pauseButton = QPushButton("Pause")
        quitButton = QPushButton("Quit")

        layout = QVBoxLayout()


How can I get my QGraphicsScene running? I'm new to Qt. Am I even supposed to be adding a QGraphicsScene to a layout/


You'll have to do something like this:

layout = QVBoxLayout()

You have added a scene to view, and it's enough. But you should add the view to your MainForm and Layout. View is a kind of widget that can be displayed by your application, while scene is not a widget and cannot be added to layout, it's a component of view. In addition, you may need to add some graphics items(e.g. rectangle, image) to scene and see how it works.

Need Your Help

Django Grappelli style is missing [Digital Ocean Setup]

python django django-admin django-grappelli

I deployed a digital ocean droplet with Django admin installed. When I installed Django Grappelli and tried to load the admin the css and js files from Django-grappelli are missing which result on ...

Upper Bound of generic class and wildcard

java generics wildcard super

class Gen <T super Number> // 1 // IS NOT ALLOWED