Drawing a line with a pixmap brush in Qt? <p>For some time I'm developing a simple drawing and painting app with Qt/C++. </p> <p>Currently I'm using QPainter::drawLine() to draw, and it works fine.</p> <p>What I want to do is drawing with pixmap brushes, which in a way I can do. I can draw with single color filled pixmaps using QPainterPath and QPainter::strokePath(). I stroke the path with a pen using a brush with the pixmap.</p> <p>In case you're still reading, my problem is, if I use a QPen and QPainter::strokePath() I get a line with tiled brush. But I want the pixmap to be drawn along the line. Like the image based brushes in some image editors. I can do that with drawRect(), but that draws the pixmaps apart.</p> <p>If you understand my problem from the gibberish I wrote, how can I draw a line with a pixmap brush?</p> <p>Edit: Here's what I do currently:</p> <pre><code>void Canvas::mouseMoveEvent(QMouseEvent *event) { polyLine[2] = polyLine[1]; polyLine[1] = polyLine[0]; polyLine[0] = event-&gt;pos(); //Some stuff here painter.drawLine(polyLine[1], event-&gt;pos()); } </code></pre> <p>This is what I tried:</p> <pre><code>void Canvas::mouseMoveEvent(QMouseEvent *event) { QPen pen(brush, brushSize, Qt::SolidLine, Qt::RoundCap, Qt::BevelJoin); //Some stuff here path.lineTo(event-&gt;pos()); painter.strokePath(path, pen); //This creates a fine line, but with a tiled brush } </code></pre> <p>To draw a pixmap along mouse movement, I tried</p> <pre><code>void Canvas::mouseMoveEvent(QMouseEvent *event) { //Some stuff QBrush brush(QPixmap(":images/fileName.png")); painter.setBrush(brush); painter.setPen(Qt::NoPen); painter.drawRect(QRect(event-&gt;pos() - brushSize / 2, event-&gt;pos() - brushSize / 2, brushSize, brushSize)); //This draws the pixmaps with intervals. } </code></pre>