Doc: replace deprecated references to QGLWidget

Remove references to the deprecated QGLWidget and replace it with
QOpenGLWidget.

Change-Id: Ia31df42ab61c25e9ce46f4491267d2c64910f55c
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
This commit is contained in:
Christian Ehrlicher 2020-03-18 19:56:40 +01:00
parent 580e9eedf7
commit bd75c87e0e
9 changed files with 29 additions and 25 deletions

View File

@ -30,8 +30,8 @@
\title 2D Painting Example
\ingroup examples-widgets-opengl
\brief The 2D Painting example shows how QPainter and QGLWidget can be used
together to display accelerated 2D graphics on supported hardware.
\brief The 2D Painting example shows how QPainter and QOpenGLWidget can be
used together to display accelerated 2D graphics on supported hardware.
\image 2dpainting-example.png
@ -39,23 +39,23 @@
paint devices provided by QPaintDevice subclasses, such as QWidget
and QImage.
Since QGLWidget is a subclass of QWidget, it is possible
Since QOpenGLWidget is a subclass of QWidget, it is possible
to reimplement its \l{QWidget::paintEvent()}{paintEvent()} and use
QPainter to draw on the device, just as you would with a QWidget.
The only difference is that the painting operations will be accelerated
in hardware if it is supported by your system's OpenGL drivers.
In this example, we perform the same painting operations on a
QWidget and a QGLWidget. The QWidget is shown with anti-aliasing
enabled, and the QGLWidget will also use anti-aliasing if the
QWidget and a QOpenGLWidget. The QWidget is shown with anti-aliasing
enabled, and the QOpenGLWidget will also use anti-aliasing if the
required extensions are supported by your system's OpenGL driver.
\section1 Overview
To be able to compare the results of painting onto a QGLWidget subclass
To be able to compare the results of painting onto a QOpenGLWidget subclass
with native drawing in a QWidget subclass, we want to show both kinds
of widget side by side. To do this, we derive subclasses of QWidget and
QGLWidget, using a separate \c Helper class to perform the same painting
QOpenGLWidget, using a separate \c Helper class to perform the same painting
operations for each, and lay them out in a top-level widget, itself
provided a the \c Window class.
@ -63,7 +63,7 @@
In this example, the painting operations are performed by a helper class.
We do this because we want the same painting operations to be performed
for both our QWidget subclass and the QGLWidget subclass.
for both our QWidget subclass and the QOpenGLWidget subclass.
The \c Helper class is minimal:
@ -81,7 +81,7 @@
The actual painting is performed in the \c paint() function. This takes
a QPainter that has already been set up to paint onto a paint device
(either a QWidget or a QGLWidget), a QPaintEvent that provides information
(either a QWidget or a QOpenGLWidget), a QPaintEvent that provides information
about the region to be painted, and a measure of the elapsed time (in
milliseconds) since the paint device was last updated.
@ -148,7 +148,7 @@
\section1 GLWidget Class Definition
The \c GLWidget class definition is basically the same as the \c Widget
class except that it is derived from QGLWidget.
class except that it is derived from QOpenGLWidget.
\snippet 2dpainting/glwidget.h 0

View File

@ -47,7 +47,7 @@
The example consist of two classes:
\list
\li \c MainWidget extends QGLWidget and contains OpenGL ES 2.0
\li \c MainWidget extends QOpenGLWidget and contains OpenGL ES 2.0
initialization and drawing and mouse and timer event handling
\li \c GeometryEngine handles polygon geometries. Transfers polygon geometry
to vertex buffer objects and draws geometries from vertex buffer objects.
@ -92,7 +92,7 @@
\section1 Loading Textures from Qt Resource Files
\c QGLWidget interface implements methods for loading textures from QImage to GL
\c QOpenGLWidget interface implements methods for loading textures from QImage to GL
texture memory. We still need to use OpenGL provided functions for specifying
the GL texture unit and configuring texture filtering options.

View File

@ -545,7 +545,7 @@
with OpenGL, but without OpenGL it avoids unnecessary re-scaling of the
background pixmap.
\li It sets render hints that increase rendering quality.
\li If OpenGL is supported, a QGLWidget viewport is assigned to the view.
\li If OpenGL is supported, a QOpenGLWidget viewport is assigned to the view.
\endlist
Finally, we start the state engine.

View File

@ -158,7 +158,7 @@ QFont QTextItem::font() const
X11 and \macos, it is the backend for painting on QImage and it is
used as a fallback for paint engines that do not support a certain
capability. In addition we provide QPaintEngine implementations for
OpenGL (accessible through QGLWidget) and printing (which allows using
OpenGL (accessible through QOpenGLWidget) and printing (which allows using
QPainter to draw on a QPrinter object).
If one wants to use QPainter to draw to a different backend,

View File

@ -123,5 +123,9 @@ void CustomItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
//! [6]
QGraphicsView view(&scene);
view.setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
QOpenGLWidget *gl = new QOpenGLWidget();
QSurfaceFormat format;
format.setSamples(4);
gl->setFormat(format);
view.setViewport(gl);
//! [6]

View File

@ -117,7 +117,7 @@
of a scene. You can attach several views to the same scene, to provide
several viewports into the same data set. The view widget is a scroll
area, and provides scroll bars for navigating through large scenes. To
enable OpenGL support, you can set a QGLWidget as the viewport by
enable OpenGL support, you can set a QOpenGLWidget as the viewport by
calling QGraphicsView::setViewport().
\snippet graphicsview.cpp 1
@ -436,10 +436,10 @@
\section2 OpenGL Rendering
To enable OpenGL rendering, you simply set a new QGLWidget as the
To enable OpenGL rendering, you simply set a new QOpenGLWidget as the
viewport of QGraphicsView by calling QGraphicsView::setViewport(). If
you want OpenGL with antialiasing, you need OpenGL sample buffer
support (see QGLFormat::sampleBuffers()).
you want OpenGL with antialiasing, you need to set a QSurfaceFormat
with the needed sample count (see QSurfaceFormat::setSamples()).
Example:

View File

@ -581,7 +581,7 @@ QGraphicsProxyWidget::~QGraphicsProxyWidget()
Note that widgets with the Qt::WA_PaintOnScreen widget attribute
set and widgets that wrap an external application or controller
cannot be embedded. Examples are QGLWidget and QAxWidget.
cannot be embedded. Examples are QOpenGLWidget and QAxWidget.
\sa widget()
*/

View File

@ -2904,7 +2904,7 @@ QGraphicsSimpleTextItem *QGraphicsScene::addSimpleText(const QString &text, cons
Note that widgets with the Qt::WA_PaintOnScreen widget attribute
set and widgets that wrap an external application or controller
are not supported. Examples are QGLWidget and QAxWidget.
are not supported. Examples are QOpenGLWidget and QAxWidget.
\sa addEllipse(), addLine(), addPixmap(), addPixmap(), addRect(),
addText(), addSimpleText(), addItem()

View File

@ -89,8 +89,8 @@ static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; // largest prime <
By default, QGraphicsView provides a regular QWidget for the viewport
widget. You can access this widget by calling viewport(), or you can
replace it by calling setViewport(). To render using OpenGL, simply call
setViewport(new QGLWidget). QGraphicsView takes ownership of the viewport
widget.
setViewport(new QOpenGLWidget). QGraphicsView takes ownership of the
viewport widget.
QGraphicsView supports affine transformations, using QTransform. You can
either pass a matrix to setTransform(), or you can call one of the
@ -159,8 +159,8 @@ static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; // largest prime <
fastest when QGraphicsView spends more time figuring out what to draw than
it would spend drawing (e.g., when very many small items are repeatedly
updated). This is the preferred update mode for viewports that do not
support partial updates, such as QGLWidget, and for viewports that need to
disable scroll optimization.
support partial updates, such as QOpenGLWidget, and for viewports that
need to disable scroll optimization.
\value MinimalViewportUpdate QGraphicsView will determine the minimal
viewport region that requires a redraw, minimizing the time spent drawing