When to use QGraphicsScene or QWidget
I'm a little confused as to WHEN you want to use a QWidget and WHEN you want to use a QGraphicsScene, could somebody elaborate on that or point me to some docs that have already covered it? I'm having a difficult time finding such information.
For instance, take the demo Tetrix, could you use a QGraphicsScene for the "board" area where all tetris blocks are? Or is QGraphicsScene limited to requiring the entire space of the window at all times?
Any help would be appreciated. Thanks!
Re: When to use QGraphicsScene or QWidget
Quote:
Originally Posted by
fossill
I'm a little confused as to WHEN you want to use a QWidget and WHEN you want to use a QGraphicsScene
Actually you always have to use QWidget or one of its subclasses. A special case of a widget is QGraphicsView which is capable of displaying QGraphicsScene and QGraphicsItems that scene contains.
Quote:
Originally Posted by
fossill
For instance, take the demo Tetrix, could you use a QGraphicsScene for the "board" area where all tetris blocks are?
Yes, you could. You can also subclass QWidget and do all of the drawing yourself, but it will be much easier if you use QGraphicsScene and QGraphicsItems.
Quote:
Originally Posted by
fossill
Or is QGraphicsScene limited to requiring the entire space of the window at all times?
No, it's not. QGraphicsView behaves just like other widgets, so you can use QWidget::setGeometry() or layouts to place it wherever you want.
Re: When to use QGraphicsScene or QWidget
If I were to make a rule of a thumb, I'd say that you should use QGraphicsView whenever you want to create a large amount of objects that either change their state very often (animate) or require interaction with the user (selecting, moving, zooming). In other situations use QWidget.