我正在使用 Qgraphicsvideoitem 使用 Qmediaplayer 显示视频。现在,如果我有圆形物品,我该如何将视频遮盖住。
这是我的代码,图像是:
VideoClass::VideoClass(QGraphicsVideoItem *parent):QGraphicsVideoItem(parent)
{
QMediaPlayer *player = new QMediaPlayer(this, QMediaPlayer::VideoSurface);
QMediaPlaylist *playlist = new QMediaPlaylist;
playlist->addMedia(QUrl::fromLocalFile("/root/Desktop/Content/Robotica_1080.wmv"));
playlist->setPlaybackMode(QMediaPlaylist::Loop);
player->setPlaylist(playlist);
player->play();
player->setVideoOutput(this);
}
void VideoClass::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
QGraphicsVideoItem::paint(painter, option, widget);
painter->drawEllipse(0, 0, 400, 400);
}
QRectF VideoClass::boundingRect() const
{
return QRectF(0,0,400,400);}