6.0.0-rc4Source

QPaintDeviceWindow Class

The QPaintDeviceWindow class is the base class for windows that are paint devices. More…

Header#include <QPaintDeviceWindow>
CMaketarget_link_libraries(app PRIVATE Nt::Gui)
ModuleNt GUI C++ Classes
InheritsQWindow, QPaintDevice
Inherited byQOpenGLWindow, QRasterWindow

List of all members, including inherited members

Public Functions

~QPaintDeviceWindow()
intwidth() const
intheight() const
qrealdevicePixelRatio() const

Reimplemented Public Functions

Public Slots

voidupdate()
voidupdate(const QRect &rect)
voidupdate(const QRegion &region)

Protected Functions

QPaintDeviceWindow()
virtual voidpaintEvent(QPaintEvent *event)

Reimplemented Protected Functions

intmetric(PaintDeviceMetric metric) const
QPaintDevice *redirected(QPoint *offset) const
voidexposeEvent(QExposeEvent *event)
voidresizeEvent(QResizeEvent *event)
boolevent(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

[protected] QPaintDeviceWindow::QPaintDeviceWindow()

Constructs a paint device window. The window is not visible.

[override] QPaintDeviceWindow::~QPaintDeviceWindow()

Destroys the window.

qreal QPaintDeviceWindow::devicePixelRatio() const

Returns the device pixel ratio of the window, as QWindow::devicePixelRatio() does.

[override, protected] bool QPaintDeviceWindow::event(QEvent *event)

Reimplements QWindow::event().

[override, protected] void QPaintDeviceWindow::exposeEvent(QExposeEvent *event)

Reimplements QWindow::exposeEvent().

int QPaintDeviceWindow::height() const

Returns the height of the window in pixels.

[override, protected] int QPaintDeviceWindow::metric(PaintDeviceMetric metric) const

Reimplements QPaintDevice::metric().

[override] QPaintEngine * QPaintDeviceWindow::paintEngine() const

Reimplements QPaintDevice::paintEngine().

[virtual, protected] 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().

[override, protected] QPaintDevice * QPaintDeviceWindow::redirected(QPoint *offset) const

Reimplements QPaintDevice::redirected().

[override, protected] void QPaintDeviceWindow::resizeEvent(QResizeEvent *event)

Reimplements QWindow::resizeEvent().

[slot] void QPaintDeviceWindow::update()

Marks the whole window as needing a repaint. The paint event is delivered from the event loop.

See also paintEvent().

[slot] void QPaintDeviceWindow::update(const QRect &rect)

This is an overloaded function.

Marks rect as needing a repaint.

[slot] void QPaintDeviceWindow::update(const QRegion &region)

This is an overloaded function.

Marks region as needing a repaint.

int QPaintDeviceWindow::width() const

Returns the width of the window in pixels.