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
x: Theme.paddingLarge
width: parent.width - Theme.paddingLarge * 2
horizontalAlignment: Text.AlignHLeft
wrapMode: Text.WordWrap
textFormat: Text.RichText
onLinkActivated: {
Qt.openUrlExternally(link)
}
}
Here is a full file: http://pastebin.com/efv6tk6R
What I have already tried:
1. Removing textFormat: Text.RichText - link stops to be link
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
x: Theme.paddingLarge
width: parent.width - Theme.paddingLarge * 2
horizontalAlignment: Text.AlignHLeft
wrapMode: Text.WordWrap
textFormat: Text.RichText
onWidthChanged: label.doLayout();
onLinkActivated: {
Qt.openUrlExternally(link)
}
}
Now all work correctly in both modes (portrait and landscape).