# Text.RichText - problem in landscape on tablet. Need help. [answered]

Hi
Can someone help me to fix my problem with RichText ? I've added a link in the Label by using textFormat: Text.RichText and everything works, but on a tablet in a landscape mode, for some reasons width of text defines the screen as a portrait mode and the right side of screen have a lot of free space (see picture).
Text.RichText_image
If I remove the textFormat: Text.RichText line, the link stops to be link and shown as a plain text.
Here is a block of Label:

Label {
text: "* Many custom icons you can find <style>a:link{color: " + Theme.highlightColor + ";}</style><a href=\"http://talk.maemo.org/showthread.php?t=92073\">here</a>.<br>* Put your custom icons (.png format ONLY) to: \"/home/nemo/Pictures/.jolla_android_icons\".<br>* Rename your icons with any file manager."
font.pixelSize: Theme.fontSizeMedium
width: parent.width - Theme.paddingLarge * 2
horizontalAlignment: Text.AlignHLeft
wrapMode: Text.WordWrap
textFormat: Text.RichText
}
}


Here is a full file: http://pastebin.com/efv6tk6R

2. Removing wrapMode line - text going over the screen
3. Changing Text.WordWrap to Text.Wrap and Text.WrapAnywhere - nothing changed, the width of text in landscape still shown like in portrait mode.
4. Removing <style>a:link{color: " + Theme.highlightColor + ";}</style> - changed only color of link (dark blue instead from theme) and the width of text in landscape still shown like in portrait mode.
5. Tried to play with parent.width - no needed result...

Please, can someone help me to fix it ?
Thanks

EDIT:
Thanks to @otsaloma for answer, it should looks like this:

Label {
id: label
text: "* Many custom icons you can find <style>a:link{color: " + Theme.highlightColor + ";}</style><a href=\"http://talk.maemo.org/showthread.php?t=92073\">here</a>.<br>* Put your custom icons (.png format ONLY) to: \"/home/nemo/Pictures/.jolla_android_icons\".<br>* Rename your icons with any file manager."
font.pixelSize: Theme.fontSizeMedium
width: parent.width - Theme.paddingLarge * 2
horizontalAlignment: Text.AlignHLeft
wrapMode: Text.WordWrap
textFormat: Text.RichText
onWidthChanged: label.doLayout();
}
}


Now all work correctly in both modes (portrait and landscape).

edit retag reopen delete

### The question has been closed for the following reason "the question is answered, an answer was accepted"by Schturman close date 2016-09-03 20:19:43.365857

Sort by » oldest newest most voted

Maybe you need to call Text.doLayout ? e.g.

Label {
id: label
...
onWidthChanged: label.doLayout();
}


In my experience this is sometimes needed, but I don't know when exactly.

more

Wow!!! it exactly what needed !!! All fixed now, thank you very much !
Probably if textFormat: Text.RichText used, width need it to work correctly in both modes (portrait and landscape).
Problem solved! :D

( 2016-09-03 20:18:46 +0200 )edit