WordWrap word boundary, non-breaking <nobr>, special character slash "/", wrap/split issue.



  • Hello, I would like to display a text composed of several words with wrapMode set to Text.WordWrap enumeration value.
    This text contains what I consider being a word which contains a special character (a slash character) in the middle of the word itself. "90km/h"
    Sadly Qt is not considering this as a single word, and is splitting the word before the "h".

    Code example:
    import QtQuick 2.2
    import QtQuick.Window 2.1

    Window {
    id: idRoot

    width: 800
    height: 480
    visible: true
    
    Rectangle {
        id: pipoRect
        width : childrenRect.width
        height: width
        color:"blue"
        Text {
            wrapMode : Text.WordWrap
            id: pipoText
            width : 530
            height :200
            color: "yellow"
    
            font.pixelSize: 24
            text: "Défaut suspension: Limitez votre vitesse à 90km/h"
    
        }
    }
    

    }

    The "word" 90km/h is split on two lines, first line shows "90km/" and second line shows "h".
    What would be the best solution to get "90km/h" not split, and displayed in this case on the second line?

    Of course this text is just one example, the text can be random, and I need a generic solution to prevent Qt to consider / as a word boundary.
    Thank you for any hint!



  • Well I thought I found a kind of solution by using this line:

    text: "Défaut suspension: Limitez votre vitesse à <nobr>90km/h</nobr>"
    But this just does not work and still provide the same result, with the "90km/" on the first line and the "h" on the second line.
    And I'm expecting "90km/h" on the second line instead :(



  • It seems ok with this!
    text: "Défaut suspension: Limitez votre vitesse à 90km\u2060/\u2060h"

    This is the unicode character for word joiner!
    Good night!
    Bill



  • This works for me as well. I have the same issue, but in QTextBlock, when text symbols immediately break after slash('/') symbol. Thanks alot for your research.



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.