QGraphicsVideoItem 类提供图形项所显示的视频产生自 QMediaObject . 更多...
头: | #include <QGraphicsVideoItem> |
qmake: | QT += multimediawidgets |
继承: | 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 ) |
附加 QGraphicsVideoItem 到 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 到 setMediaObject () 函数。
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();
注意 :每次只可以把单个显示输出附加到媒体对象。
另请参阅 QMediaObject , QMediaPlayer ,和 QVideoWidget .
如何比例缩放视频以拟合图形项的大小。
访问函数:
Qt::AspectRatioMode | aspectRatioMode () const |
void | setAspectRatioMode (Qt::AspectRatioMode mode ) |
This property holds the media object which provides the video displayed by a graphics item.
访问函数:
virtual QMediaObject * | mediaObject () const override |
此特性保持视频的本机大小。
访问函数:
QSizeF | nativeSize () const |
通知程序信号:
void | nativeSizeChanged (const QSizeF & size ) |
此特性保持视频项的偏移。
QGraphicsVideoItem 将使用其左上角的偏移绘制视频。
访问函数:
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.
访问函数:
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
。范例展示如何将视频帧渲染到
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);
该特性在 Qt 5.15 引入。
访问函数:
QAbstractVideoSurface * | videoSurface () const |
另请参阅 QMediaPlayer::setVideoOutput .
构造显示视频的图形项。
The parent 会被传递给 QGraphicsItem .
[signal]
void
QGraphicsVideoItem::
nativeSizeChanged
(const
QSizeF
&
size
)
发射信号当本机 size 对于视频已改变。
注意: 通知程序信号对于特性 nativeSize .
[虚拟]
QGraphicsVideoItem::
~QGraphicsVideoItem
()
销毁视频图形项。
[override virtual]
QRectF
QGraphicsVideoItem::
boundingRect
() const
重实现: QGraphicsItem::boundingRect () const.
[override virtual]
void
QGraphicsVideoItem::
paint
(
QPainter
*
painter
, const
QStyleOptionGraphicsItem
*
option
,
QWidget
*
widget
= nullptr)
重实现: QGraphicsItem::paint (QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget).