Important: Please read the Qt Code of Conduct -

qtextedit - heading (from setmarkdown)

  • Dear Qt-experts!

    With the latest QT version, I can import markdown formatted text directly into qtextedit, edit the text and then save the qtextedit content to a markdown formatted text.

    The markdown parser correctly reads heading-markers in the markdown file and correctly represents in the qtextedit field.

    Now I'd like to allow the user to add additional headings in the qtextedit field (not just plain text) and then to save this again to markdown.

    Thus my question: How can I add headings?
    I know how to change e.g. font-types, font sizes etc, but not how to allow adding a new heading...

    Any ideas, hints are greatly apprechiated!

    (using pyqt5.14)

  • In case someone searches also for this, I found the solution:
    c = self.textedit.textCursor()
    fmt = c.blockFormat()

    where LevelInteger is the level of the heading

Log in to reply