- Qt 6.8
- Qt Widgets
- C++ Classes
- QGraphicsScene
- Qt 6.8.1 Reference Documentation

# Obsolete Members for QGraphicsScene

The following members of class QGraphicsScene are deprecated. They are provided to keep old source code working. We strongly advise against using them in new code.

## Protected Functions

`(deprecated)` virtual void | drawItems(QPainter *painter, int numItems, QGraphicsItem *[] items, const QStyleOptionGraphicsItem[] options, QWidget *widget = nullptr)

## Member Function Documentation

### `[virtual protected, deprecated]` void QGraphicsScene::drawItems(QPainter *painter, int numItems, QGraphicsItem *[] items, const QStyleOptionGraphicsItem[] options, QWidget *widget = nullptr)

This function is deprecated. We strongly advise against using it in new code.

Paints the given items using the provided painter, after the background has been drawn, and before the foreground has been drawn. All painting is done in scene coordinates. Before drawing each item, the painter must be transformed using QGraphicsItem::sceneTransform().

The options parameter is the list of style option objects for each item in items. The numItems parameter is the number of items in items and options in options. The widget parameter is optional; if specified, it should point to the widget that is being painted on.

The default implementation prepares the painter matrix, and calls QGraphicsItem::paint() on all items. Reimplement this function to provide custom painting of all items for the scene; gaining complete control over how each item is drawn. In some cases this can increase drawing performance significantly.

Example:

     void CustomScene::drawItems(QPainter *painter, int numItems,
                                 QGraphicsItem *items[],
                                 const QStyleOptionGraphicsItem options[],
                                 QWidget *widget)
     {
         for (int i = 0; i < numItems; ++i) {
              // Draw the item
              painter->save();
              painter->setTransform(items[i]->sceneTransform(), true);
              items[i]->paint(painter, &options[i], widget);
              painter->restore();
          }
     }

Since Qt 4.6, this function is not called anymore unless the QGraphicsView::IndirectPainting flag is given as an Optimization flag.

See also drawBackground() and drawForeground().