Important: Please read the Qt Code of Conduct -

Append <li> </li> Html element in TextArea

  • Hello,

    I'm trying to append HTML list element in a TextArea.

    Here is a sample of my code :

            id : result
            width: 400
            height: 600
            x: 760
            y: 60
            readOnly: true
            textFormat: Text.RichText
            text: "<ul><b>Actions :</b>"
    function onClickButton(){
            result.append("<li>text as list element</li>)

    But I don't have the list HTML style. When I do the same at the declaration of the TextArea it works but when I append it does not.
    Does anybody know why ? And eventualy how to make it works ?
    Thank you

  • @DavidM29
    I don't claim to know anything about QML.

    I don't know if this is relevant, but:

    text: "<ul><b>Actions :</b>"

    • Where is your </ul>?
    • I'm surprised you can put that <b>Actions :</b> in, I thought <ul>s were only intended to have <li>s as their children (though I admit it seems to work).
    • result.append("<li>text as list element</li>): once you have put your </ul> in, you won't simply be able to append(), as you'll need to insert it prior to the </ul>.

  • Thank you for your answer :

    • In HTML the </ul> can be added after it should not block the list to appear. I've made a sample code here to proove it : (even if I admit it is not clean...)

    • The <b>Actions</b> is here only the make the text bold so there is no problem using it you can combine with more styling if you want

    • Even with the </ul> it does not work

  • As long as I don't have any solution, I have decided to add the list element symbol manualy via the JS code : "\u2022"

Log in to reply