Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Word wrap in QML rectangle

Word wrap in QML rectangle

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 3 Posters 3.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DRoscoe
    wrote on 2 Nov 2016, 13:59 last edited by
    #1

    Consider the following code:

    Rectangle {
              id: message_row
              Layout.fillWidth: true
              Layout.fillHeight: true
    
              color: "transparent"
    
              RowLayout {
                anchors.fill: parent
                spacing: 0
    
                Rectangle {
                  anchors.fill: parent
                  color: "transparent"
    
                  Text {
                    id: message_text
                    text: getText()
                    font: tap_fonts.default_font
                    verticalAlignment: Text.AlignVCenter
                    horizontalAlignment: Text.AlignHCenter
    
                    anchors.fill: parent
    
                    wrapMode: Text.WordWrap
                  }
                }
              }
            }
    

    What I am finding is that the message text is not always wrapping. Depending on what machine I am running on, or platform it either works fine, or the text is centered with the left and right ends truncated.

    Am I doing something wrong?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on 2 Nov 2016, 17:55 last edited by
      #2

      Hi! Could you please check if this also happens when the Text isn't placed in a RowLayout (actually in no layout at all)? Smells like QTBUG-33097.

      1 Reply Last reply
      1
      • V Offline
        V Offline
        Vicky Sharma
        wrote on 4 Nov 2016, 12:41 last edited by
        #3

        @DRoscoe
        I run your code and figured out that you must need to define width and height of first Rectangle. So try it first and let me know if any issue come again..

        D 1 Reply Last reply 4 Nov 2016, 12:45
        1
        • V Vicky Sharma
          4 Nov 2016, 12:41

          @DRoscoe
          I run your code and figured out that you must need to define width and height of first Rectangle. So try it first and let me know if any issue come again..

          D Offline
          D Offline
          DRoscoe
          wrote on 4 Nov 2016, 12:45 last edited by
          #4

          @Vicky-Sharma That did the trick. Still not sure why it sometimes works without that such as on the iPad or some of our computers.

          1 Reply Last reply
          0

          1/4

          2 Nov 2016, 13:59

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved