Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for MCUs
  4. Alignment issue when displaying Multi Line Text
QtWS25 Last Chance

Alignment issue when displaying Multi Line Text

Scheduled Pinned Locked Moved Unsolved Qt for MCUs
multiline textqmltext componenttextarea
3 Posts 3 Posters 612 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.
  • P Offline
    P Offline
    Pavankumar S V
    wrote on 27 Oct 2022, 10:40 last edited by Pavankumar S V
    #1

    Hello,
    I'm trying to display multi line text in a "ScrollView". But the displayed text in the device has alignment issue.

    Please find the qml code below:

    import QtQuick 2.0
    import QtQuick.Controls 2.3
    
    ScrollView {
    
    		clip: true
    		anchors.fill: parent
    		ScrollBar.vertical.policy: (message.height>650 || ulTnCpopup.height<640)?ScrollBar.AlwaysOn:ScrollBar.AsNeeded
    		ScrollBar.horizontal.policy: ScrollBar.AsNeeded
    		ScrollBar.vertical.interactive: true
    		ScrollBar.horizontal.interactive: true
    
    		contentHeight : message.height + 100
    		contentWidth : ulTnCpopup.width
    
    		Rectangle{
    			id: poprect
    			anchors.fill: parent
    
    			Text {
    				id: message
    				width : ulTnCpopup.width - 30
    				wrapMode : Text.WordWrap
    				anchors.leftMargin: poprect.width/30
    				anchors.topMargin: poprect.height/30
    				font.family: ulTnCpopup.fontfmly
    				font.pointSize: (ulTnCpopup.width < 640) ? 8 : 12
    				color: "black"
    				text: loginobj.webObj?applicationData.userlogin_readTnC_file(loginobj.tncTextFile):qsTr("
            REGISTRATION ACCESS AND USE
    
               1.  This following sets out the terms and conditions on which you may use the content on business-standard.com 
                   website, business-standard.com's mobile browser site, Business Standard instore Applications and other digital
                   publishing services (www.smartinvestor.in, www.bshindi.com and www.bsmotoring,com) owned by Business 
                   Standard Private Limited, all the services herein will be referred to as Business Standard Content Services.
    
               2.  We welcome users to register on our digital platforms. We offer the below mentioned registration services which
                   may be subject to change in the future. All changes will be appended in the terms and conditions page and 
                   communicated to existing users by email.
    
               3.  All information received by us from your registration on business-standard.com or other digital products of
                   Business Standard will be used by Business Standard in accordance with our Privacy Policy. Kindly read the 
                   below mentioned details.")
                }
            }
    }
    

    I have also attached the image of how the text is displayed on the device.
    Please help me to solve this alignment issue.multiLineText_Issue.png

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 27 Oct 2022, 12:08 last edited by
      #2

      It's not an alignment issue. You just hardcoded line breaks and leading whitespace in your text. Since the device has narrower display these line breaks just don't go in the same places as they do in the source qml.

      Remove the line breaks from source and it will be ok.

      1 Reply Last reply
      1
      • J Offline
        J Offline
        JoeCFD
        wrote on 27 Oct 2022, 14:53 last edited by
        #3

        Also try to add in Text:
        horizontalAlignment: Text.AlignJustify

        1 Reply Last reply
        0

        2/3

        27 Oct 2022, 12:08

        • Login

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