Important: Please read the Qt Code of Conduct -

Implementing QAbstractTextDocumentLayout::draw

  • Hello, everyone.

    I'm having a lot of trouble understanding what am I supposed to to on the draw implementation of a QAbstractTextDocumentLayout specialization I'm writing.

    The problem is that I only receive a QPainter and a PaintContext. I don't know much about all the things a QPainter is capable of doing, as I'm still learning, but I believe there is not enough information for me to determine which block of the document I'm supposed to print first... The only thing I get is the cursor position, which is not enough information.

    Should I just draw the whole document an then clip by the context's clip rectangle? Isn't this a waste of effort?

    I'm implementing a document layout to be associated with a QTextDocument that will be shown by a QTextEdit widget.

    I really need your help... What would help is an explanation about what is what in the parameters I get and how everything connects with the QTextEdit viewport, because the documentation of this method is terrible!!

    Thank you.