Solved Why plus 1 when getting the content height of QTextEdit?
-
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
-
Hi,
You have the answer in the same thread you are linking to.
-
@SGaist But I can't find answer. Is my question too vague? I don't know why need plus 1, +1
-
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.