概述:我们利用QGraphicView和QGraphicScene来实现一个简单的视频播放器,然后上面悬浮一些操作的控件,看看怎么来实现。
1、CcTestVideoPlayer类
模拟播放器类,继承QGraphicScene
1.1 CcTestVideoPlayer.h
#pragma once
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QVariant>
#include <QSharedPointer>
class CcTestVideoPlayer : public QGraphicsView
{
Q_OBJECT
public:
CcTestVideoPlayer(QWidget *parent = nullptr, QGraphicsScene* scene = nullptr);
~CcTestVideoPlayer(void);
protected:
void drawBackground(QPainter *painter, const QRectF &rect)override;
};
1.2 CcTestVideoPlayer.cpp
#include "CcTestVideoPlayer.h"
#include <QLabel>
#include <QStyle>
#include <QPainter>
#include <QPaintEngine>
#include <QGraphicsProxyWidget>
#include <QMenu>
#include <QApplication>
#include <QTimer>
CcTestVideoPlayer::CcTestVide