Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTextDocument keep pageSize when resizing editor.

QTextDocument keep pageSize when resizing editor.

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 860 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jan-Willem
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      J 1 Reply Last reply
      2
      • SGaistS SGaist

        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.

        J Offline
        J Offline
        Jan-Willem
        wrote on last edited by
        #3

        @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.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved