How to do it...

Let's get started by following these steps:

  1. We will create a new class called RenderWindow, which inherits from the QOpenGLWindow class. Go to File | New File or Project, then select C++ Class under Files and Classes category. Name the class RenderWindow and set its base class as QOpenGLWindow. Then, proceed to create the C++ class:
  1. Go to the renderwindow.h file we just created and add the following headers at the top of the source code:
#include <GL/glu.h>#include <QtOpenGL>#include <QSurfaceFormat>#include <QOpenGLFunctions>#include <QOpenGLWindow>#include <QOpenGLBuffer>#include <QOpenGLVertexArrayObject>#include <QOpenGLShader> ...

Get Qt5 C++ GUI Programming Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.