QVideoWidget Class

The QVideoWidget class provides a widget which presents video produced by a media object. More...

Header: #include <QVideoWidget>
CMake: find_package(Qt6 REQUIRED COMPONENTS MultimediaWidgets)
target_link_libraries(mytarget PRIVATE Qt6::MultimediaWidgets)
qmake: QT += multimediawidgets
Inherits: QWidget

Properties

Public Functions

QVideoWidget(QWidget *parent = nullptr)
virtual ~QVideoWidget()
Qt::AspectRatioMode aspectRatioMode() const
bool isFullScreen() const
QVideoSink *videoSink() const

Reimplemented Public Functions

virtual QSize sizeHint() const override

Public Slots

void setAspectRatioMode(Qt::AspectRatioMode mode)
void setFullScreen(bool fullScreen)

Signals

void aspectRatioModeChanged(Qt::AspectRatioMode mode)
void fullScreenChanged(bool fullScreen)

Reimplemented Protected Functions

virtual bool event(QEvent *event) override
virtual void hideEvent(QHideEvent *event) override
virtual void moveEvent(QMoveEvent *event) override
virtual void resizeEvent(QResizeEvent *event) override
virtual void showEvent(QShowEvent *event) override

Detailed Description

Attaching a QVideoWidget to a QMediaPlayer or QCamera allows it to display the video or image output of that object.

player = new QMediaPlayer;
player->setSource(QUrl("http://example.com/myclip1.mp4"));

videoWidget = new QVideoWidget;
player->setVideoOutput(videoWidget);

videoWidget->show();
player->play();

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

See also QCamera, QMediaPlayer, and QGraphicsVideoItem.

Property Documentation

aspectRatioMode : Qt::AspectRatioMode

how video is scaled with respect to its aspect ratio.

Access functions:

Qt::AspectRatioMode aspectRatioMode() const
void setAspectRatioMode(Qt::AspectRatioMode mode)

Notifier signal:

void aspectRatioModeChanged(Qt::AspectRatioMode mode)

fullScreen : bool

This property holds whether video display is confined to a window or is fullScreen.

Access functions:

bool isFullScreen() const
void setFullScreen(bool fullScreen)

Notifier signal:

void fullScreenChanged(bool fullScreen)

Member Function Documentation

[explicit] QVideoWidget::QVideoWidget(QWidget *parent = nullptr)

Constructs a new video widget.

The parent is passed to QWidget.

[virtual] QVideoWidget::~QVideoWidget()

Destroys a video widget.

[override virtual protected] bool QVideoWidget::event(QEvent *event)

Reimplements: QWidget::event(QEvent *event).

Current event event. Returns the value of the base class QWidget::event(QEvent *event) function.

[override virtual protected] void QVideoWidget::hideEvent(QHideEvent *event)

Reimplements: QWidget::hideEvent(QHideEvent *event).

Handles the hide event.

[override virtual protected] void QVideoWidget::moveEvent(QMoveEvent *event)

Reimplements: QWidget::moveEvent(QMoveEvent *event).

Handles the move event.

[override virtual protected] void QVideoWidget::resizeEvent(QResizeEvent *event)

Reimplements: QWidget::resizeEvent(QResizeEvent *event).

Handles the resize event.

[override virtual protected] void QVideoWidget::showEvent(QShowEvent *event)

Reimplements: QWidget::showEvent(QShowEvent *event).

Handles the show event.

[override virtual] QSize QVideoWidget::sizeHint() const

Reimplements an access function for property: QWidget::sizeHint.

Returns the size hint for the current back end, if there is one, or else the size hint from QWidget.

[invokable] QVideoSink *QVideoWidget::videoSink() const

Returns the QVideoSink instance.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.