IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)

QGraphicsVideoItem Class

The QGraphicsVideoItem class provides a graphics item which display video produced by a QMediaPlayer or QCamera.

Article lu   fois.

L'auteur

Liens sociaux

Viadeo Twitter Facebook Share on Google+   

QGraphicsVideoItem Class

  • Header: QGraphicsVideoItem

  • CMake:

    find_package(Qt6 REQUIRED COMPONENTS MultimediaWidgets)

    target_link_libraries(mytarget PRIVATE Qt6::MultimediaWidgets)

  • qmake: QT += multimediawidgets

  • Inherits: QGraphicsObject

  • Group: QGraphicsVideoItem is part of multimedia

Detailed Description

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

 
Sélectionnez
player = new QMediaPlayer(this);

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

player->setSource(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

Property Documentation

 

aspectRatioMode : Qt::AspectRatioMode

how a video is scaled to fit the graphics item's size.

Access functions:

  • aspectRatioMode() const

  • void setAspectRatioMode( mode)

[read-only] nativeSize : const QSizeF

This property holds the native size of the video.

Access functions:

  • nativeSize() const

Notifier signal:

  • void nativeSizeChanged(const &size)

offset : QPointF

This property holds the video item's offset.

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

Access functions:

  • offset() const

  • void setOffset(const &offset)

size : QSizeF

This property holds the video item's size.

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

Access functions:

  • size() const

  • void setSize(const &size)

[read-only] videoSink : QVideoSink* const

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

 
Sélectionnez
QGraphicsVideoItem *item = new QGraphicsVideoItem;
graphicsView->scene()->addItem(item);
graphicsView->show();
QImage img = QImage("images/qt-logo.png").convertToFormat(QImage::Format_ARGB32);
item->videoSink()->setVideoFrame(QVideoFrame(img));

Access functions:

  • *videoSink() const

See Also

Member Function Documentation

 

[explicit] QGraphicsVideoItem::QGraphicsVideoItem(QGraphicsItem *parent = nullptr)

Constructs a graphics item that displays video.

The parent is passed to QGraphicsItem.

[virtual] QGraphicsVideoItem::~QGraphicsVideoItem()

Destroys a video graphics item.

[override virtual] QRectF QGraphicsVideoItem::boundingRect() const

[override virtual] void QGraphicsVideoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr)

[override virtual] int QGraphicsVideoItem::type() const

Reimplements: QGraphicsItem::type() const.

Returns an int representing the type of the video item.

Vous avez aimé ce tutoriel ? Alors partagez-le en cliquant sur les boutons suivants : Viadeo Twitter Facebook Share on Google+