Hello! I’m writing my application in QML, and inside a TextArea formatted with RichText I want to display this:

a header

(an empty line)

another header

my first thought was to go with a <br> tag, but it has a problem: it creates 2 empty lines, don’t know why. so doing this

<h1>hello</h1>
<br>
<h2>world</h2>

produces

hello

(an empty line)
(an empty line)

world

I tried using the <pre> tag:

<pre>
</pre>

but no empty lines were displayed

the only working workaround was to use a non breaking space &nbsp;, but being it a TextArea, the user is able to edit the text, and so there would be a “rogue” space instead of an empty line. How can I display just a single line break between two headers (or even paragraphs, but in my case the header is needed)?

  • ono@lemmy.ca
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    Does Qt Quick expose Qt’s markdown support? That could be another way to populate a rich text control, perhaps letting you work around the problem.

  • MagicShel@programming.dev
    link
    fedilink
    arrow-up
    1
    ·
    1 year ago

    The mismatch between rich text and html has been a pain for pretty much ever.

    Have you tried putting the br on the line above instead of on its own? Barring that can you assign a css class and just create the vertical separation you want?

  • tubbadu@lemmy.kde.socialOP
    link
    fedilink
    arrow-up
    0
    ·
    1 year ago

    replying to @ono@lemmy.ca because for strange reasons I’m unable to reply directly to him:

    Does Qt Quick expose Qt’s markdown support? That could be another way to populate a rich text control, perhaps letting you work around the problem.

    yes this worked!!!

    # title
    <br>
    # title
    

    I have to use <br> instead of <br> otherwise it don’t work, I don’t know why

    I would have rather used a RichText way, but this one does what I need, thank you very much!

    • ono@lemmy.ca
      link
      fedilink
      English
      arrow-up
      1
      ·
      1 year ago

      I have to use <br> instead of <br>

      I suspect those two tags were different when you wrote them, and Lemmy mangled them like it did in my comments. Can you describe the tags you originally wrote, to avoid the mangling? I’m curious about what exactly worked for you.