QGraphicsVideoItem

The QGraphicsVideoItem class provides a graphics item which display video produced by a QMediaObject . More

Inheritance diagram of PySide2.QtMultimediaWidgets.QGraphicsVideoItem

Synopsis

Functions

Signals

Detailed Description

Attaching a QGraphicsVideoItem to a QMediaObject allows it to display the video or image output of that media object. A QGraphicsVideoItem is attached to a media object by passing a pointer to the QMediaObject to the setMediaObject() function.

player = new QMediaPlayer(this);

QGraphicsVideoItem *item = new QGraphicsVideoItem;
player->setVideoOutput(item);
graphicsView->scene()->addItem(item);
graphicsView->show();

player->setMedia(QUrl("http://example.com/myclip4.ogv"));
player->play();

Note : Only a single display output can be attached to a media object at one time.

See also

QMediaObject QMediaPlayer QVideoWidget

class PySide2.QtMultimediaWidgets.QGraphicsVideoItem([parent=None])

Constructs a graphics item that displays video.

The parent is passed to QGraphicsItem .

PySide2.QtMultimediaWidgets.QGraphicsVideoItem.aspectRatioMode()
Return type:

AspectRatioMode

This property holds how a video is scaled to fit the graphics item’s size..

PySide2.QtMultimediaWidgets.QGraphicsVideoItem.nativeSize()
Return type:

PySide2.QtCore.QSizeF

This property holds the native size of the video..

PySide2.QtMultimediaWidgets.QGraphicsVideoItem.nativeSizeChanged(size)
Parameters:

sizePySide2.QtCore.QSizeF

PySide2.QtMultimediaWidgets.QGraphicsVideoItem.offset()
Return type:

PySide2.QtCore.QPointF

This property holds the video item’s offset..

QGraphicsVideoItem will draw video using the offset for its top left corner.

PySide2.QtMultimediaWidgets.QGraphicsVideoItem.setAspectRatioMode(mode)
Parameters:

modeAspectRatioMode

This property holds how a video is scaled to fit the graphics item’s size..

PySide2.QtMultimediaWidgets.QGraphicsVideoItem.setOffset(offset)
Parameters:

offsetPySide2.QtCore.QPointF

This property holds the video item’s offset..

QGraphicsVideoItem will draw video using the offset for its top left corner.

PySide2.QtMultimediaWidgets.QGraphicsVideoItem.setSize(size)
Parameters:

sizePySide2.QtCore.QSizeF

This property holds the video item’s size..

QGraphicsVideoItem will draw video scaled to fit size according to its fillMode.

PySide2.QtMultimediaWidgets.QGraphicsVideoItem.size()
Return type:

PySide2.QtCore.QSizeF

This property holds the video item’s size..

QGraphicsVideoItem will draw video scaled to fit size according to its fillMode.

PySide2.QtMultimediaWidgets.QGraphicsVideoItem.videoSurface()
Return type:

PySide2.QtMultimedia.QAbstractVideoSurface

This property holds Returns the underlying video surface that can render video frames to the current item. This property is never nullptr . Example of how to render video frames to QGraphicsVideoItem :.

QGraphicsVideoItem *item = new QGraphicsVideoItem;
graphicsView->scene()->addItem(item);
graphicsView->show();
QImage img = QImage("images/qt-logo.png").convertToFormat(QImage::Format_ARGB32);
QVideoSurfaceFormat format(img.size(), QVideoFrame::Format_ARGB32);
item->videoSurface()->start(format);
item->videoSurface()->present(img);

See also

setVideoOutput