First, you have your logic turned around backwards. The scroll area should be the central widget for the MainWindow, you should put a layout inside that, and then you should add your "MyWidget" instance into the layout. My widget should not be managing the scroll area, it should be the other way around.

Second, the items in QGraphicsScene instances are rendered into QGraphicsView instances. There is really no need for you to have a "MyWidget" class, simply put the QGraphicsView as the widget managed by the layout in the scroll area.

Finally, there will be no scrollbars if the scene is smaller than the view. You might be drawing into a QRect that is 500 x 500, but nowhere do you tell the scene that your custom text object is that big.

There are many examples of the Graphics / View architecture in the Qt distribution, including some that do the same things you are trying to do.