You can ask QTextDocument and its text layout for the size of the document it holds.