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. QplainTextEdit bottom margin (empty space below text)
Qt 6.11 is out! See what's new in the release blog

QplainTextEdit bottom margin (empty space below text)

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 805 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.
  • S Offline
    S Offline
    sugz
    wrote on last edited by
    #1

    Hi everyone
    I'm trying to add an empty space below the text in a QPlainTextEdit, allow the user to scroll past the text.
    You can find this in visual studio, visual studio code or sublime for example

    I've managed to to it on a QTextEdit like this:

    QTextFrameFormat format = document()->rootFrame()->frameFormat();
    format.setBottomMargin(contentsRect().height());
    document()->rootFrame()->setFrameFormat(format);
    

    but it doesn't work with a QPlainTextEdit

    Here is what i'm trying to achieve implemented in a QTextEdit:
    code_editor_empty_space.PNG

    Any ideas are welcome.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      Tecnoll
      wrote on last edited by
      #2

      You need to use this method:

      class CodeEditor(QPlainTextEdit):
          ...
          
          self.setCenterOnScroll(True)
      

      Official documentation reference

      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