Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Why plus 1 when getting the content height of QTextEdit?

Why plus 1 when getting the content height of QTextEdit?

Scheduled Pinned Locked Moved Solved Qt for Python
4 Posts 2 Posters 459 Views 1 Watching
  • 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.
  • I Offline
    I Offline
    ideaplus
    wrote on last edited by
    #1

    Why plus 1 when getting the content height of QTextEdit?
    c++

    QMargins margins = textEdit->contentsMargins();
    QSizeF documentSize =  textEdit->document()->size();
    int height = documentSize.height() + margins.top() + margins.bottom() + 1;
    

    python

    margins = self.textEdit.contentsMargins()
    size = self.textEdit.document().size()
    height = size.height() + margins.top() + margins.bottom() + 1
    

    https://forum.qt.io/topic/87934/set-exact-height-for-qplaintextedit-according-to-height/3

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

      Hi,

      You have the answer in the same thread you are linking to.

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

      1 Reply Last reply
      0
      • I Offline
        I Offline
        ideaplus
        wrote on last edited by ideaplus
        #3

        @SGaist But I can't find answer. Is my question too vague? I don't know why need plus 1, +1

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

          Did you read the last post of the thread ? It contains two links: one points to a Qt bug report where the logic is explained and another one that points to the QPlainTextEdit documentation.

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

          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