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. Change the space between TextField line and text
Forum Updated to NodeBB v4.3 + New Features

Change the space between TextField line and text

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 3 Posters 821 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.
  • A Offline
    A Offline
    Amanda0211
    wrote on last edited by Amanda0211
    #1

    I am using Material Design and I want to change the distance between the line and the text of a TextField.

    8d2fff09-da7b-4dbe-a02b-da923c306ab4-image.png

    Is there any property inside the TextField that can change that?

    1 Reply Last reply
    0
    • MarkkyboyM Offline
      MarkkyboyM Offline
      Markkyboy
      wrote on last edited by
      #2

      TelField?

      Anyway, without seeing your code, it was not too easy to workout where that lower line is coming from, I'm fairly certain it is not part of TextField or TextInput, but I could be wrong.

      However, I can reproduce something similar and a simply declaration of implicit height set on background item allows vertical adjustment between characters and lower line.

      import QtQuick 2.12
      import QtQuick.Window 2.12
      import QtQuick.Controls 2.12
      
      Window {
          width: 640
          height: 480
          visible: true
          color: "black"
          title: qsTr("Hello World")
      
          TextField {
              color: "white"
              text: "5000"
              font.pixelSize: 36
              anchors.centerIn: parent
              background: Item {
                  implicitWidth: 200
                  implicitHeight: 180 // reduce this figure and see line height decrease
                  Rectangle {
                      color: "white"
                      height: 3
                      width: parent.width
                      anchors.bottom: parent.bottom
                  }
              }
          }
      }
      

      Don't just sit there standing around, pick up a shovel and sweep up!

      I live by the sea, not in it.

      1 Reply Last reply
      0
      • GrecKoG Offline
        GrecKoG Offline
        GrecKo
        Qt Champions 2018
        wrote on last edited by
        #3

        @Markkyboy said in Change the space btween TelField line and TextField Text:

        TelField?

        Context..

        Anyway, OP is using the Material style TextField, this one has a line.
        It's position is calcluated by default like this : y: textField.height - height - textField.bottomPadding + 8
        The 8 is the distance between the line and the text. To increase it you can modify the y of the background:

        TextField {
            background.y: height - background.height - bottomPadding + 12
        }
        

        You might need to change the bottomPadding value if you want to keep a distance between the line and the bottom of the TextField (by default the bottomPadding is 16).

        A 1 Reply Last reply
        2
        • GrecKoG GrecKo

          @Markkyboy said in Change the space btween TelField line and TextField Text:

          TelField?

          Context..

          Anyway, OP is using the Material style TextField, this one has a line.
          It's position is calcluated by default like this : y: textField.height - height - textField.bottomPadding + 8
          The 8 is the distance between the line and the text. To increase it you can modify the y of the background:

          TextField {
              background.y: height - background.height - bottomPadding + 12
          }
          

          You might need to change the bottomPadding value if you want to keep a distance between the line and the bottom of the TextField (by default the bottomPadding is 16).

          A Offline
          A Offline
          Amanda0211
          wrote on last edited by
          #4

          @GrecKo thank you! That is what I was looking for!

          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