Obsolete Members for QGLWidget

以下成员源于类 QGLWidget 已过时。 提供它们是为使旧源代码能继续工作。强烈建议不要在新代码中使用它们。

公共函数

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

成员函数文档编制

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.

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

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 格式 。使用 isSharing () to see whether sharing is in effect.

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.

注意: 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 或使用 QOpenGLContext API in conjunction with QWindow . There is currently no officially supported way to substitute QGLWidget 's context with your own implementation of QGLContext .

另请参阅 context () 和 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 ,和 initializeGL () function will be executed for this new context before the first resizeGL () 或 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.

另请参阅 format (), isSharing (),和 isValid ().