QGLWidget
QGLWidget
#include <QGLWidget>
Public Functions
QGLWidget(QWidget *parent = nullptr, const QGLWidget *shareWidget = nullptr, Qt::WindowFlags f = ...) | |
QGLWidget(QGLContext *context, QWidget *parent = nullptr, const QGLWidget *shareWidget = nullptr, Qt::WindowFlags f = ...) | |
QGLWidget(const QGLFormat &format, QWidget *parent = nullptr, const QGLWidget *shareWidget = nullptr, Qt::WindowFlags f = ...) | |
virtual | ~QGLWidget() |
GLuint | bindTexture(const QImage &image, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA) |
GLuint | bindTexture(const QPixmap &pixmap, GLenum target, GLint format, QGLContext::BindOptions options) |
GLuint | bindTexture(const QImage &image, GLenum target, GLint format, QGLContext::BindOptions options) |
GLuint | bindTexture(const QPixmap &pixmap, GLenum target = GL_TEXTURE_2D, GLint format = GL_RGBA) |
GLuint | bindTexture(const QString &fileName) |
const QGLColormap & | colormap() const |
QGLContext * | context() const |
void | deleteTexture(GLuint id) |
void | doneCurrent() |
bool | doubleBuffer() const |
void | drawTexture(const QRectF &target, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D) |
void | drawTexture(const QPointF &point, GLuint textureId, GLenum textureTarget = GL_TEXTURE_2D) |
QGLFormat | format() const |
QImage | grabFrameBuffer(bool withAlpha = false) |
bool | isSharing() const |
bool | isValid() const |
void | makeCurrent() |
void | makeOverlayCurrent() |
const QGLContext * | overlayContext() const |
void | qglClearColor(const QColor &c) const |
void | qglColor(const QColor &c) const |
QPixmap | renderPixmap(int w = 0, int h = 0, bool useContext = false) |
void | renderText(int x, int y, const QString &str, const QFont &font = QFont()) |
void | renderText(double x, double y, double z, const QString &str, const QFont &font = QFont()) |
void | setColormap(const QGLColormap &cmap) |
void | swapBuffers() |
- 219 public functions inherited from QWidget
- 34 public functions inherited from QObject
- 14 public functions inherited from QPaintDevice
Public Slots
virtual void | updateGL() |
virtual void | updateOverlayGL() |
Static Public Members
QImage | convertToGLFormat(const QImage &img) |
Protected Functions
bool | autoBufferSwap() const |
virtual void | glDraw() |
virtual void | glInit() |
virtual void | initializeGL() |
virtual void | initializeOverlayGL() |
virtual void | paintGL() |
virtual void | paintOverlayGL() |
virtual void | resizeGL(int width, int height) |
virtual void | resizeOverlayGL(int width, int height) |
void | setAutoBufferSwap(bool on) |
Reimplemented Protected Functions
virtual bool | event(QEvent *e) override |
virtual void | paintEvent(QPaintEvent *event) override |
virtual void | resizeEvent(QResizeEvent *event) override |
- 35 protected functions inherited from QWidget
- 9 protected functions inherited from QObject
- 1 protected function inherited from QPaintDevice
Additional Inherited Members
- 59 properties inherited from QWidget
- 1 property inherited from QObject
- 3 signals inherited from QWidget
- 2 signals inherited from QObject
- 1 public variable inherited from QWidget
- 1 public variable inherited from QObject
- 1 protected slot inherited from QWidget
- 2 protected variables inherited from QObject
- 1 protected type inherited from QPaintDevice
详细说明
QGLWidget类是一个用于渲染OpenGL图形的小部件。
QGLWidget提供了显示集成到Qt应用程序中的OpenGL图形的功能。它使用起来非常简单。您可以继承它并像使用其他QWidget一样使用子类,只是您可以在使用QPainter和标准OpenGL渲染命令之间进行选择。
注意:这个类是遗留的QtOpenGL模块的一部分,和其他QGL类一样,在新的应用程序中应该避免使用。相反,从Qt 5.4开始,更喜欢使用QOpenGLWidget和QOpenGL类。
QGLWidget提供了三个方便的虚拟函数,您可以在子类中重新实现这些函数来执行典型的OpenGL任务:
paintGL()-渲染OpenGL场景。在需要更新小部件时调用。
resizeGL()-设置OpenGL视口、投影等。每当调整小部件的大小时(以及由于所有新创建的小部件都会自动获得调整大小事件而首次显示时)调用。
initializeGL()-设置OpenGL渲染上下文、定义显示列表等。在第一次调用resizeGL()或paintGL()之前调用一次。
class MyGLDrawer : public QGLWidget { Q_OBJECT // must include this if you use Qt signals/slots public: MyGLDrawer(QWidget *parent) : QGLWidget(parent) {} protected: void initializeGL() { // Set up the rendering context, define display lists etc.: ... glClearColor(0.0, 0.0, 0.0, 0.0); glEnable(GL_DEPTH_TEST); ... } void resizeGL(int w, int h) { // setup viewport, projection etc.: glViewport(0, 0, (GLint)w, (GLint)h); ... glFrustum(...); ... } void paintGL() { // draw the scene: ... glRotatef(...); glMaterialfv(...); glBegin(GL_QUADS); glVertex3f(...); glVertex3f(...); ... glEnd(); ... } };
##############################
QQ 3087438119
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
2022-06-19 QPainter 画点
2021-06-19 基于BIM ifc的施工模拟扩展测试日志
2020-06-19 IfcBoundingBox
2020-06-19 IfcBooleanResult
2019-06-19 labelimg data