Home > Back-end >  Text only partially visible in QML TextEdit
Text only partially visible in QML TextEdit

Time:09-29

I have a text edit in QML, but the problem is that when I run the app it shows only parts of some letters, here is what it looks like: enter image description here

This is the code for the the text edit plus the parents:

StackLayout {
        id: stack_layout

        anchors.left: menu.right
        anchors.right: parent.right
        anchors.top: parent.top
        anchors.bottom: parent.bottom
        anchors.rightMargin: 0
        anchors.topMargin: 0
        anchors.leftMargin: 0
        anchors.bottomMargin: 0
        
        currentIndex: 1

        HomeScreen {
            id: home_screen
        }

        Rectangle{
            color: "#303030"

            anchors.left: menu.right
            anchors.right: parent.right
            anchors.top: parent.top
            anchors.bottom: parent.bottom
            anchors.rightMargin: 0
            anchors.leftMargin: 0
            anchors.bottomMargin: 0
            anchors.topMargin: 0

            TextField{
                height: 20

                font.family: "Times New Roman"
                font.pixelSize: 30
                wrapMode: Text.Wrap

                horizontalAlignment: Text.AlignLeft
                verticalAlignment: Text.AlignVCenter

                anchors.left: parent.left
                anchors.right: parent.right
                anchors.top: parent.top

                anchors.rightMargin: 100
                anchors.leftMargin: 100
                anchors.topMargin: 75

                Material.accent: Material.Cyan
            }
        }
}

So what is the problem?

CodePudding user response:

Ok so I figured out the solution to the problem, the problem was that the height of the text field was too small so it got cut off so I just added: height: 52, and the problem was fixed.

tip: make sure the height of the TextField is 20 or more than the font size. Since the font size was 30, I made the height 50-60.

  • Related