QTextDocument keep pageSize when resizing editor.



  • In the TextEdit example I added a line in the load-function in where the pageSize of the document is set. It works as expected and when checking the returned pageSize is (of course) the same as the pageSize set.

    When I maximize/restore the application (Debian Jessie/Stretch) however, the pageSize is not set any more.

    Is this the normal behaviour?
    Is there a way to keep the pageSize without setting it again and again?


  • Lifetime Qt Champion

    Hi,

    Taking a look at QTextEdit sources, it seems that the resizeEvent reimplementation does things depending on the line wrap set for the QTextEdit. You should check with that.



  • @SGaist said in QTextDocument keep pageSize when resizing editor.:

    Hi,

    Taking a look at QTextEdit sources, it seems that the resizeEvent reimplementation does things depending on the line wrap set for the QTextEdit. You should check with that.

    After looking into the source code, I added something like:

    textEdit->setLineWrapMode(QTextEdit::FixedPixelWidth);
    textEdit->setLineWrapColumnOrWidth(pageSize.width);
    

    Works like a charm! I've often worked through the source code of QTextEdit, QTextDocument and QTextDocumentLayout, but failed to notice this one.

    Thanks SGaist.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.