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. qtextedit - heading (from setmarkdown)

qtextedit - heading (from setmarkdown)

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 701 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.
  • H Offline
    H Offline
    hermes
    wrote on last edited by
    #1

    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!

    Ulrich
    (using pyqt5.14)

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hermes
      wrote on last edited by
      #2

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

      where LevelInteger is the level of the heading

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved