Thanks for the tip, Jacek.

However, I can't get anything to appear via QAbstractTextDocumentLayout::draw(). For example, here is some test code that doesn't work:

Qt Code:
  1. QTextDocument td( "test" );
  2. QAbstractTextDocumentLayout::PaintContext ctx;
  3. ctx.clip = QRectF( 0, 0, 400, 100 );
  4. qPainter->drawRect( ctx.clip ); // Test that I'm drawing in the right area
  5. td.documentLayout()->draw( qPainter, ctx );
To copy to clipboard, switch view to plain text mode 

The clip rectangle gets drawn properly, but no text is drawn.

I've tried looking at how QTextEdit draws its QTextDocument, and I can't see anything significantly different to what I am doing, but obviously there must be something..

Any ideas?