The QGraphicsVideoItem class provides a graphics item which display video produced by a QMediaObject. More...
Header: | #include <QGraphicsVideoItem> |
qmake: | QT += multimediawidgets |
Inherits: | QGraphicsObject and QMediaBindableInterface |
|
|
QGraphicsVideoItem(QGraphicsItem *parent = nullptr) | |
virtual | ~QGraphicsVideoItem() |
Qt::AspectRatioMode | aspectRatioMode() const |
QSizeF | nativeSize() const |
QPointF | offset() const |
void | setAspectRatioMode(Qt::AspectRatioMode mode) |
void | setOffset(const QPointF &offset) |
void | setSize(const QSizeF &size) |
QSizeF | size() const |
QAbstractVideoSurface * | videoSurface() const |
virtual QRectF | boundingRect() const override |
virtual QMediaObject * | mediaObject() const override |
virtual void | paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override |
void | nativeSizeChanged(const QSizeF &size) |
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, and QVideoWidget.
how a video is scaled to fit the graphics item's size.
Access functions:
Qt::AspectRatioMode | aspectRatioMode() const |
void | setAspectRatioMode(Qt::AspectRatioMode mode) |
This property holds the media object which provides the video displayed by a graphics item.
Access functions:
virtual QMediaObject * | mediaObject() const override |
This property holds the native size of the video.
Access functions:
QSizeF | nativeSize() const |
Notifier signal:
void | nativeSizeChanged(const QSizeF &size) |
This property holds the video item's offset.
QGraphicsVideoItem will draw video using the offset for its top left corner.
Access functions:
QPointF | offset() const |
void | setOffset(const QPointF &offset) |
This property holds the video item's size.
QGraphicsVideoItem will draw video scaled to fit size according to its fillMode.
Access functions:
QSizeF | size() const |
void | setSize(const QSizeF &size) |
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);
This property was introduced in Qt 5.15.
Access functions:
QAbstractVideoSurface * | videoSurface() const |
See also QMediaPlayer::setVideoOutput.
Constructs a graphics item that displays video.
The parent is passed to QGraphicsItem.
[signal]
void QGraphicsVideoItem::nativeSizeChanged(const QSizeF &size)
Signals that the native size of the video has changed.
Note: Notifier signal for property nativeSize.
[virtual]
QGraphicsVideoItem::~QGraphicsVideoItem()
Destroys a video graphics item.
[override virtual]
QRectF QGraphicsVideoItem::boundingRect() const
Reimplements: QGraphicsItem::boundingRect() const.
[override virtual]
void QGraphicsVideoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr)
Reimplements: QGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget).
© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-5.15/qgraphicsvideoitem.html