Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qrasterwindow.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
6
7#include <QtGui/private/qpaintdevicewindow_p.h>
8
9#include <QtGui/QBackingStore>
10#include <QtGui/QPainter>
11
13
14/*!
15 \class QRasterWindow
16 \inmodule QtGui
17 \since 5.4
18 \brief QRasterWindow is a convenience class for using QPainter on a QWindow.
19
20 QRasterWindow is a QWindow with a raster-based, non-OpenGL surface. On top of
21 the functionality offered by QWindow, QRasterWindow adds a virtual
22 paintEvent() function and the possibility to open a QPainter on itself. The
23 underlying paint engine will be the raster one, meaning that all drawing will
24 happen on the CPU. For performing accelerated, OpenGL-based drawing, use
25 QOpenGLWindow instead.
26
27 Internally the class is thin wrapper for QWindow and QBackingStore
28 and is very similar to the \l{Raster Window Example}{Raster Window
29 Example} that uses these classes directly.
30
31 \sa QPaintDeviceWindow::paintEvent(), QPaintDeviceWindow::update()
32*/
33
35{
36 Q_DECLARE_PUBLIC(QRasterWindow)
37public:
39 {
41 if (backingstore->size() != q->size())
43 }
44
46 {
48 const QSize size = q->size();
49 if (backingstore->size() != size)
51
53 }
54
56 {
58 }
59
61 {
64 }
65
67};
68
69/*!
70 Constructs a new QRasterWindow with \a parent.
71*/
72QRasterWindow::QRasterWindow(QWindow *parent)
73 : QPaintDeviceWindow(*(new QRasterWindowPrivate), parent)
74{
75 setSurfaceType(QSurface::RasterSurface);
76 d_func()->backingstore.reset(new QBackingStore(this));
77}
78
79QRasterWindow::~QRasterWindow()
80{
81 Q_D(QRasterWindow);
82 // Delete backingstore while window is still alive, as it
83 // might need to reference the window in the process
84 d->backingstore.reset(nullptr);
85}
86
87/*!
88 \internal
89*/
90int QRasterWindow::metric(PaintDeviceMetric metric) const
91{
92 Q_D(const QRasterWindow);
93
94 switch (metric) {
95 case PdmDepth:
96 return d->backingstore->paintDevice()->depth();
97 default:
98 break;
99 }
100 return QPaintDeviceWindow::metric(metric);
101}
102
103/*!
104 \internal
105*/
106QPaintDevice *QRasterWindow::redirected(QPoint *) const
107{
108 Q_D(const QRasterWindow);
109 return d->backingstore->paintDevice();
110}
111
112void QRasterWindow::resizeEvent(QResizeEvent *)
113{
114}
115
116QT_END_NAMESPACE
117
118#include "moc_qrasterwindow.cpp"
Combined button and popup list for selecting options.