Qt 5.6 | Qt OpenGL | C++ Classes | QGLWidget

Qt 5.6.2 Reference Documentation

# Obsolete Members for QGLWidget

The following members of class QGLWidget are obsolete. They are provided to keep old source code working. We strongly advise against using them in new code.

## Public Functions

`(obsolete)` void | setContext(QGLContext *context, const QGLContext *shareContext = Q_NULLPTR, bool deleteOldContext = true)
`(obsolete)` void | setFormat(const QGLFormat &format)

## Member Function Documentation

### void QGLWidget::setContext(QGLContext *context, const QGLContext *shareContext = Q_NULLPTR, bool deleteOldContext = true)

Sets a new context for this widget. The QGLContext context must be created using new. QGLWidget will delete context when another context is set or when the widget is destroyed.

If context is invalid, QGLContext::create() is performed on it. The initializeGL() function will then be executed for the new context before the first resizeGL() or paintGL().

If context is invalid, this method will try to keep display list and texture object sharing in effect, or (if shareContext points to a valid context) start display list and texture object sharing with that context, but sharing might be impossible if the two contexts have different formats. Use isSharing() to see whether sharing is in effect.

If deleteOldContext is true (the default), the existing context will be deleted. You may use false here if you have kept a pointer to the old context (as returned by context()), and want to restore that context later.

Note: This function is obsolete and should no longer be used. If you were using it to recreate the context for a QGLWidget, you should instead create a new QGLWidget or use the QOpenGLContext API in conjunction with QWindow. There is currently no officially supported way to substitute QGLWidget's context with your own implementation of QGLContext.

See also context() and isSharing().

### void QGLWidget::setFormat(const QGLFormat &format)

Sets a new format for this widget.

If the underlying OpenGL/Window system cannot satisfy all the features requested in format, the nearest subset of features will be used. After creation, the format() method will return the actual rendering context format obtained.

The widget will be assigned a new QGLContext, and the initializeGL() function will be executed for this new context before the first resizeGL() or paintGL().

This method will try to keep display list and texture object sharing in effect with other QGLWidget objects, but changing the format might make sharing impossible. Use isSharing() to see if sharing is still in effect.

See also format(), isSharing(), and isValid().