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. minimumPixelSize is not Working during Text wrap
Forum Updated to NodeBB v4.3 + New Features

minimumPixelSize is not Working during Text wrap

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 615 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.
  • M Offline
    M Offline
    Madesh R
    wrote on last edited by
    #1

    Hi ,
    Find below the code snippet
    Text {
    anchors {
    left: parent.left
    right: parent.right
    verticalCenter: parent.verticalCenter
    }
    text: qsTrId(strAlarmMsg)
    fontSizeMode: Text.Fit
    minimumPixelSize: 10
    wrapMode: Text.WordWrap
    font.pixelSize: iAlarmMsgPixelSize
    color: strMsgFontColor
    horizontalAlignment:Text.AlignHCenter
    }

    In this I'm getting expected behaviour , that text should be wrapped to the given size of parent. However , Sometimes the text is spilling out of boundaries.Tried minimumPixelSize, but this seems not working

    J 1 Reply Last reply
    0
    • M Madesh R

      Hi ,
      Find below the code snippet
      Text {
      anchors {
      left: parent.left
      right: parent.right
      verticalCenter: parent.verticalCenter
      }
      text: qsTrId(strAlarmMsg)
      fontSizeMode: Text.Fit
      minimumPixelSize: 10
      wrapMode: Text.WordWrap
      font.pixelSize: iAlarmMsgPixelSize
      color: strMsgFontColor
      horizontalAlignment:Text.AlignHCenter
      }

      In this I'm getting expected behaviour , that text should be wrapped to the given size of parent. However , Sometimes the text is spilling out of boundaries.Tried minimumPixelSize, but this seems not working

      J Offline
      J Offline
      JasmineSethi
      wrote on last edited by JasmineSethi
      #2

      @Madesh-R Hi, check this code if it will solve your problem.

      import QtQuick 2.9
      import QtQuick.Window 2.2

      Window
      {
      visible: true
      width: 600
      height: 600

      Rectangle
      {
          width:  parent.width * 0.50
          height: parent.height * 0.40
          color: "black"
          anchors.centerIn: parent
      
          Text
          {
              anchors
              {
                  left: parent.left
                  right: parent.right
                  verticalCenter: parent.verticalCenter
              }
              text: "hello kdlkda ksdlkdk kdlkdlk kalk"
              fontSizeMode: Text.Fit
              minimumPixelSize: 10
              wrapMode: Text.WordWrap
              font.pixelSize: 20
              color: "white"
              horizontalAlignment:Text.AlignHCenter
      

      // width: parent.width
      // height: parent.height
      }
      }
      }

      M 2 Replies Last reply
      1
      • J JasmineSethi

        @Madesh-R Hi, check this code if it will solve your problem.

        import QtQuick 2.9
        import QtQuick.Window 2.2

        Window
        {
        visible: true
        width: 600
        height: 600

        Rectangle
        {
            width:  parent.width * 0.50
            height: parent.height * 0.40
            color: "black"
            anchors.centerIn: parent
        
            Text
            {
                anchors
                {
                    left: parent.left
                    right: parent.right
                    verticalCenter: parent.verticalCenter
                }
                text: "hello kdlkda ksdlkdk kdlkdlk kalk"
                fontSizeMode: Text.Fit
                minimumPixelSize: 10
                wrapMode: Text.WordWrap
                font.pixelSize: 20
                color: "white"
                horizontalAlignment:Text.AlignHCenter
        

        // width: parent.width
        // height: parent.height
        }
        }
        }

        M Offline
        M Offline
        Madesh R
        wrote on last edited by
        #3

        @JasmineSethi

        Thanks for the respone Jasmine. Will verify... :)

        1 Reply Last reply
        0
        • J JasmineSethi

          @Madesh-R Hi, check this code if it will solve your problem.

          import QtQuick 2.9
          import QtQuick.Window 2.2

          Window
          {
          visible: true
          width: 600
          height: 600

          Rectangle
          {
              width:  parent.width * 0.50
              height: parent.height * 0.40
              color: "black"
              anchors.centerIn: parent
          
              Text
              {
                  anchors
                  {
                      left: parent.left
                      right: parent.right
                      verticalCenter: parent.verticalCenter
                  }
                  text: "hello kdlkda ksdlkdk kdlkdlk kalk"
                  fontSizeMode: Text.Fit
                  minimumPixelSize: 10
                  wrapMode: Text.WordWrap
                  font.pixelSize: 20
                  color: "white"
                  horizontalAlignment:Text.AlignHCenter
          

          // width: parent.width
          // height: parent.height
          }
          }
          }

          M Offline
          M Offline
          Madesh R
          wrote on last edited by
          #4

          @JasmineSethi

          Hi Jasmine ,
          Have verified your solution . And it's working fine.A very minor modification needed to be done

          Text
          {

              width: parent.width
              height: parent.height
              anchors
              {
                  left: parent.left
                  right: parent.right
                  verticalCenter: parent.verticalCenter
              }
              text: "DELVERED VOLUME MISMATCH DELVERED VOLUME MISMATCH DELVERED VOLUME MISMATCH DELVERED VOLUME MISMATCH DELVERED VOLUME MISMATCH DELVERED VOLUME MISMATCH DELVERED VOLUME MISMATCH"
              fontSizeMode: Text.Fit
              minimumPixelSize: 1
              wrapMode: Text.WordWrap
              font.pixelSize: 20
              color: "red"
              horizontalAlignment:Text.AlignHCenter
              verticalAlignment: Text.AlignVCenter
          

          }

          Thanks a lot...

          1 Reply Last reply
          1

          • Login

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