#include#include // ... QPainter painter(this); QPixmap bg("bg.png"); painter.drawTiledPixmap(rect(), bg);
#includeThis code creates a checkerboard pattern using the diagonal cross pattern and the drawRect method. Package library: Qt Widgets or QMainWindow.#include // ... QPainter painter(this); QBrush brush(Qt::black, Qt::DiagCrossPattern); painter.setBrush(brush); painter.drawRect(rect());