Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Auto format Markdown text in QML textarea/text edit



  • I am trying to implement the same feature as that of Slack where in a user can type a markdown text such as (asterisk asterisk) hello (asterisk asterisk) and it automatically converts to markdown version in the same TextArea.

    I read the documentation and tested it and it doesnt do auto detect and replace,
    so i was planning to listen to onTextChanged event and just reset the text but unfortunately, the Markdown format doesnt reflect.

    if I type (asterisk)(asteriks) hello (asterisk) (asterisk), and reset it back to textArea.text = text

    TextArea {
              id: mainText
              anchors.fill : parent
              textFormat: TextEdit.MarkdownText
         
               onTextChanged: {
                        mainText.text = text;
                }
    

    Is there a way to do this in QML? im using 5.15. If not any suggestion on how to do this?


Log in to reply