Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. How to stretch rectangle height with label?
QtWS25 Last Chance

How to stretch rectangle height with label?

Scheduled Pinned Locked Moved Solved Mobile and Embedded
4 Posts 2 Posters 886 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
    Pyroxar
    wrote on last edited by
    #1

    I have:
    https://pastebin.com/8jZ201jn

    How to stretch rectangle height with label?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      Kofr
      wrote on last edited by
      #2

      it will help you http://doc.qt.io/qt-5/qml-qtquick-textmetrics.html

      1 Reply Last reply
      1
      • P Offline
        P Offline
        Pyroxar
        wrote on last edited by Pyroxar
        #3
        TextMetrics {
                                    id: textMetrics
                                    //font.family: "Arial"
                                    elide: Text.ElideMiddle
                                    //textWarp:
                                    elideWidth: Screen.width
                                    text: "Stworzyliśmy olbrzymią bazę pytań z egzaminów zawodowych! Napracowaliśmy się co nie miara, ale było warto - pytania pochodzą wprost z arkuszy egzaminacyjnych i jest ich łącznie aż 1691 (758 pytań E.12 + 568 pytań E.13 + 365 pytań E.14). Znajdziesz tutaj także wyjątkowe wykłady i tutoriale video, dostępne całkowicie za darmo!"
        
                                }
        

        but textMetrics.boundingRect.height is only 15

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Pyroxar
          wrote on last edited by Pyroxar
          #4

          I used layout previous but i had:

          Layout.preferredWidth: Screen.width/2
          

          and

          height: childrenRect.height
          

          in rectangle, this don't work.

          I had to change

          height: childrenRect.height
          

          property on

          Layout.preferredHeight: childrenRect.height
          

          and this working:

          Rectangle{
          	Layout.alignment: Qt.AlignTop | Qt.AlignHCenter
          	Layout.preferredWidth: Screen.width/2
          	Layout.preferredHeight: childrenRect.height
          	color: "red"
          
          	Label{
          	    width: parent.width
          	    wrapMode: Text.WordWrap
          	    text: "Stworzyliśmy olbrzymią bazę pytań z egzaminów zawodowych! Napracowaliśmy się co nie miara, ale było warto - pytania pochodzą wprost 			   z arkuszy egzaminacyjnych i jest ich łącznie aż 1691 (758 pytań E.12 + 568 pytań E.13 + 365 pytań E.14). Znajdziesz tutaj także 			   wyjątkowe wykłady i tutoriale video, dostępne całkowicie za darmo!"
          	    font.pointSize: 18
          	    color: "#8E9198"
          	    horizontalAlignment: Text.AlignHCenter
          	    verticalAlignment: Text.AlignVCenter
          	}
          }
          
          1 Reply Last reply
          0

          • Login

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