QPaintDeviceWindow Class
The QPaintDeviceWindow class is the base class for windows that are paint devices. More…
| Header | #include <QPaintDeviceWindow> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Gui) |
| Module | Nt GUI C++ Classes |
| Inherits | QWindow, QPaintDevice |
| Inherited by | QOpenGLWindow, QRasterWindow |
List of all members, including inherited members
Public Functions
| ~QPaintDeviceWindow() | |
| int | width() const |
| int | height() const |
| qreal | devicePixelRatio() const |
Reimplemented Public Functions
| QPaintEngine * | paintEngine() const |
Public Slots
Protected Functions
| QPaintDeviceWindow() | |
| virtual void | paintEvent(QPaintEvent *event) |
Reimplemented Protected Functions
| int | metric(PaintDeviceMetric metric) const |
| QPaintDevice * | redirected(QPoint *offset) const |
| void | exposeEvent(QExposeEvent *event) |
| void | resizeEvent(QResizeEvent *event) |
| bool | event(QEvent *event) |
Detailed Description
The window owns a backing store. When the window needs painting, which is when it is exposed or when update() asks for it, it calls paintEvent() with the region to paint. Paint on the window with a QPainter:
void MyWindow::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.fillRect(event->rect(), Qt::white);
}
See also QRasterWindow, QWindow and QBackingStore.
Differences from Qt
The window always paints in software, into a QImage. Qt's class is the base of QOpenGLWindow as well. Nt does not call paintEvent() before the window is exposed.
Member Function Documentation
QPaintDeviceWindow::QPaintDeviceWindow()
Constructs a paint device window. The window is not visible.
QPaintDeviceWindow::~QPaintDeviceWindow()
Destroys the window.
qreal QPaintDeviceWindow::devicePixelRatio() const
Returns the device pixel ratio of the window, as QWindow::devicePixelRatio() does.
bool QPaintDeviceWindow::event(QEvent *event)
Reimplements QWindow::event().
void QPaintDeviceWindow::exposeEvent(QExposeEvent *event)
Reimplements QWindow::exposeEvent().
int QPaintDeviceWindow::height() const
Returns the height of the window in pixels.
int QPaintDeviceWindow::metric(PaintDeviceMetric metric) const
Reimplements QPaintDevice::metric().
QPaintEngine * QPaintDeviceWindow::paintEngine() const
Reimplements QPaintDevice::paintEngine().
void QPaintDeviceWindow::paintEvent(QPaintEvent *event)
Handles the paint event event: paint its region of the window. Use a QPainter on the window. The default does nothing.
See also update().
QPaintDevice * QPaintDeviceWindow::redirected(QPoint *offset) const
Reimplements QPaintDevice::redirected().
void QPaintDeviceWindow::resizeEvent(QResizeEvent *event)
Reimplements QWindow::resizeEvent().
void QPaintDeviceWindow::update()
Marks the whole window as needing a repaint. The paint event is delivered from the event loop.
See also paintEvent().
void QPaintDeviceWindow::update(const QRect &rect)
This is an overloaded function.
Marks rect as needing a repaint.
void QPaintDeviceWindow::update(const QRegion ®ion)
This is an overloaded function.
Marks region as needing a repaint.
int QPaintDeviceWindow::width() const
Returns the width of the window in pixels.