<br> formatting problem in QLabel
-
Hello,
I have a problem with some text I want to display inside cells of a QTableWidget.
Some of the cells are initialized withsetCellWidget( row, col, cellLabel );
cellLabel is basically a QLabel which contents is set with something like
setText( "<center>1 (2) </center><font color=#000000>09:12 : <b>titre Normal</b></font><br/><font color=#FF1144>12:10 : <b>titre Rouge</b></font><br/>" );
this gives the following result, where "09:12 : " and "titre Normal" end up on different lines.
If I add a <br/> after the </center>, the hours and title are on the same line but I get an extra blank line between the "1 (2)" and the following lines.
In my example, I would like to have only 3 lines:
1 (2)
09:12 : titre Normal
12:10 : titre RougeHow could I achieve this?
-
@torea
For unknown reason, you are showing that<font color=#000000>09:12 : <b>titre Normal</b></font><br/>
splits the line, while seemingly-identical
<font color=#FF1144>12:10 : <b>titre Rouge</b></font><br/>
appears not to.
I don't know the answer, other than playing around, but you seem to know your HTML so I would try using
<span>
and/or<div>
elements. Or, maybe play with
if you absolutely have to. Etc.P.S.
If @VRonin sees you usingsetCellWidget()
at all you will be in trouble! Since he will advise using aQStyledItemDelegate
here instead, you might want to change your code over to that, and then deal with any problems. Though I don't know whether text there is allowed to be HTML/rich-text or just plain text. -
Thanks for the hints.
Some other parts of the software use the HTML formatting so I'm supposed to keep the HTML.
I'll try to play with the elements you mentioned and will check if the QStyledItemDelegate can accept HTML.If nothing works, we'll probably stick to the "blank line" solution
-