rendered paste bodyvoid LinesEditor::printWhiteSpaces( QPainter &p ){ const int contentsY = verticalScrollBar()->value(); const qreal pageBottom = contentsY + viewport()->height(); const QFontMetrics fm = QFontMetrics( currentFont() ); for ( QTextBlock block = document()->begin(); block.isValid(); block = block.next() ) { QTextLayout* layout = block.layout(); const QRectF boundingRect = layout->boundingRect(); QPointF position = layout->position(); if ( position.y() +boundingRect.height() < contentsY ) continue; if ( position.y() > pageBottom ) break; const QString txt = block.text(); const int len = txt.length(); for ( int i=0; i<len; i++) { QPixmap *p1 = 0; if (txt[i] == ' ' ) p1 = &spacePixmap; else if (txt[i] == '\t' ) p1 = &tabPixmap; else continue; // pixmaps are of size 8x8 pixels QTextCursor cursor = textCursor(); cursor.setPosition( block.position() + i, QTextCursor::MoveAnchor); QRect r = cursorRect( cursor ); int x = r.x() + 4; int y = r.y() + fm.height() / 2 - 5; p.drawPixmap( x, y, *p1 ); } }}