Important: Please read the Qt Code of Conduct -

QML framework Bug found , text Area and Markdown, garbage remain after emptying content

  • using an ordinary text area in QML, setting it up with a markup formatting. using the header "#" markup.

    after deleting all the content using backspace, it will appear that the text area is empty.
    after typing a single letter, the text will appear as usual but, the actual content of the TextArea.txt will contant the "#" deleted previously.

    here is the QML code

    import QtQuick 2.15
    import QtQuick.Window 2.15
    import QtQuick.Controls 2.12
    Window {
        width: 640
        height: 480
        visible: true
        title: qsTr("Hello World")
        id: mainWindow
        TextArea {
                id: mainText
                    anchors.fill : parent
                    textFormat: TextEdit.MarkdownText
                    text: "# Header"
                    Keys.onPressed: {
                    if(event.key === Qt.Key_B && (event.modifiers & Qt.ControlModifier )){
                        // for debugging
                        console.debug("main text is ", mainText.text);

    Steps to reproduce

    1. Here I have a TextArea with Markdown formatting, after running this application, it will display the correct header.
    2. Now, delete the content of the TextArea using backspace until all text is gone.
    3. once confirmed, press Ctrl + B, it will print/dump the content of the text area, it is empty and length is 0.
    4. now type a single character in the text area, it will appear as expected in the running UI... BUT..
    5. when pressing Ctrl+B again to dump the content of mainText.text, the text Area will have the "#" plus the character typed in #4. Ex: "# s" assuming "s" was the character typed.

    my environment
    QT Creator 5.0.1 based on QT 5.15.2 (VS2019, 64 bit)

    I was trying to report this bug in QT bug report tool but I dont know what categories this should be placed.

Log in to reply