Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

minimumPixelSize is not Working during Text wrap



  • 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



  • @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
    }
    }
    }



  • @JasmineSethi

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



  • @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...


Log in to reply