Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Append <li> </li> Html element in TextArea

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

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 1.4k Views
  • 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.
  • D Offline
    D Offline
    DavidM29
    wrote on 24 May 2018, 15:06 last edited by
    #1

    Hello,

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

    Here is a sample of my code :

    TextArea{
            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

    J 1 Reply Last reply 24 May 2018, 15:26
    0
    • D DavidM29
      24 May 2018, 15:06

      Hello,

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

      Here is a sample of my code :

      TextArea{
              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

      J Offline
      J Offline
      JonB
      wrote on 24 May 2018, 15:26 last edited by
      #2

      @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>.
      1 Reply Last reply
      0
      • D Offline
        D Offline
        DavidM29
        wrote on 25 May 2018, 05:53 last edited by DavidM29
        #3

        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 : https://www.w3schools.com/code/tryit.asp?filename=FRNJF4EU655R (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

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DavidM29
          wrote on 28 May 2018, 05:42 last edited by
          #4

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

          1 Reply Last reply
          1

          3/4

          25 May 2018, 05:53

          • Login

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