1、创建基于OpenGLWidget基类的子类
XVideoWidget.h
#ifndef XVIDEOWIDGET_H
#define XVIDEOWIDGET_H
#include <QOpenGLWidget>
class XVideoWidget : public QOpenGLWidget
{
public:
XVideoWidget(QWidget *parent);
~XVideoWidget();
protected:
//刷新显示
void paintGL();
//初始化gl
void initializeGL();
// 窗口尺寸变化
void resizeGL(int width, int height);
};
#endif // XVIDEOWIDGET_H
XVideoWidget.cpp
#include "XVideoWidget.h"
#include <QDebug>
XVideoWidget::XVideoWidget(QWidget *parent): QOpenGLWidget(parent)
{
}
XVideoWidget::~XVideoWidget()
{
}
//初始化gl
void XVideoWidget::initializeGL()
{
qDebug() << "initializeGL";
}
//刷新显示
void XVideoWidget::paintGL()
{
qDebug() << "paintGL";
}
// 窗口尺寸变化
void XVideoWidget::resizeGL(int width, int height)
{
qDebug() << "resizeGL "<<width<<":"<<height;
}
2、打开ui设计页面

本文介绍了如何基于OpenGLWidget创建自定义子类XVideoWidget,并实现其初始化、绘制及窗口尺寸调整等功能。通过实例演示了从创建类到UI设计集成的全过程。
最低0.47元/天 解锁文章
882

被折叠的 条评论
为什么被折叠?



