Search code examples
c++qteventsresizeqtextedit

What event (if any) does QTextEdit fire when the size of its content changes?


As the title says, how can I receive notification whenever a multi-line QTextEdit changes the size of its content?

(Note: content size is different from the control size, i.e. I want to know when lines were added or removed, or changed height because of a font change).


Solution

  • QTextEdit has a textChanged() signal which will do what you want. From the docs:

    "This signal is emitted whenever the document's content changes; for example, when text is inserted or deleted, or when formatting is applied."

    I wasn't sure if formatting included font changes but I tested it and it does.