this post was submitted on 12 Aug 2023
8 points (100.0% liked)

Programming

13375 readers
8 users here now

All things programming and coding related. Subcommunity of Technology.


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.

founded 1 year ago
MODERATORS
 

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)?

you are viewing a single comment's thread
view the rest of the comments
[–] ono@lemmy.ca 3 points 1 year ago* (last edited 1 year ago) (4 children)

Just a guess, but have you tried <p></p> ?

Or a single p tag with or without a slash after the p? (Lemmy keeps mangling this one when I write it explicitly.)

https://doc.qt.io/qt-6/richtext-html-subset.html

[–] mifan@feddit.dk 1 points 1 year ago (3 children)
[–] tubbadu@lemmy.kde.social 1 points 1 year ago (2 children)

If I write some text inside the tags yes, a single line is created, but with the text. I want a blank line, and unfortunately empty tags are apparently stripped out by the textarea

[–] Obscerno@lemm.ee 2 points 1 year ago* (last edited 1 year ago) (1 children)

What about a non-breaking space?

Edit: I just realized you addressed that in the post.

[–] tubbadu@lemmy.kde.social 1 points 1 year ago

it's what I'm currently doing, but was hoping to find a better solution... thank you anyway!