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. Text not in the center of TextField, when creating a rounded TextField
Forum Updated to NodeBB v4.3 + New Features

Text not in the center of TextField, when creating a rounded TextField

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 3 Posters 1.2k Views 1 Watching
  • 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.
  • AmrCoderA Offline
    AmrCoderA Offline
    AmrCoder
    wrote on last edited by
    #1

    Hi,

    Iam using the following code to create a rounded TextField

            TextField {
                id: usernameTextField
                placeholderText: qsTr("username")
                width: 250
                height: 40
                anchors {
                    top: parent.top
                    topMargin: giveDetailsLabel.anchors.topMargin + 36
                    horizontalCenter: parent.horizontalCenter
                    horizontalCenterOffset: 0
                }
    
                background: Rectangle {
                    radius: 20
                    border.color: "#C9C9C9"
                    border.width: 1
                }
                verticalAlignment: TextField.AlignVCenter
    
                font.pixelSize: 16
                font.weight: Font.Normal
                font.family: "Open Sans"
                leftPadding: 10
            }
    

    The problem with the following code, the text is not in the center it's shifted up for some reason and I try many different ways to put it in the center but never.

    Capture.PNG

    also, it looks very ugly when it deployed on Android

    another question is I have the same exactly textfield but i used

    echoMode: TextField.Password
    

    to make the password, the password dots are so big, I try to decrease the font but the text also decrease before it convert to dot, so how to decrease the dot only without decrease the text size so user see what they are writting in big font before the character converts, here how it looks on Android
    Capture.PNG

    and also again the text shifted up and for dots for character and never center inside the text

    1 Reply Last reply
    0
    • F Offline
      F Offline
      flowery
      wrote on last edited by
      #2

      I am not seeing any issue in your code .By default the vertical alignment in TextField is center only. Without this statement "verticalAlignment: TextField.AlignVCenter", it should work .
      Did you check the same code output in Windows ?
      Just make sure whether it is a problem with platform.

      1 Reply Last reply
      0
      • AmrCoderA Offline
        AmrCoderA Offline
        AmrCoder
        wrote on last edited by
        #3

        yes I tested so far on Windows, Mac, IOS, Android, they all give the same you see them all shifted up like this, is that the normal look? what you think? also any idea about decrease the size of the password character the dot characters? as they look very bad on mobile phones very big in size.

        1 Reply Last reply
        0
        • F Offline
          F Offline
          flowery
          wrote on last edited by
          #4

          1753b6c1-5a5c-4397-9d3c-d93e822393c8-image.png
          I am not seeing this issue in Windows .My Qtversion is 5.12

          1 Reply Last reply
          0
          • AmrCoderA Offline
            AmrCoderA Offline
            AmrCoder
            wrote on last edited by
            #5

            I tested with QT 5.15 and it worked good, the issues seems with Qt 6.2, anyway when I tried the

            QQuickStyle::setStyle("Universal");
            

            or Material it cause this issue, on old versions of QT, but on QT 6.2 it seems no matter what I does it still the same, you can change the style to Material or Universal you will get the same issue.

            1 Reply Last reply
            0
            • ndiasN Offline
              ndiasN Offline
              ndias
              wrote on last edited by
              #6

              I was only able to reproduce the problem when using the theme material in conjunction with Qt6. When QT5 is used or the theme material is not used the problem does not happen.

              You can check the bug report system to see if there's something related with. Maybe you can open a new ticket providing a description and a minimal script reproducing the issue.

              I had already found other bugs before related to the theme material.

              Regards

              1 Reply Last reply
              1
              • AmrCoderA Offline
                AmrCoderA Offline
                AmrCoder
                wrote on last edited by
                #7

                Thank you very much for testing this, yes I think it's an issue, I even tested on QT Gallary example that comes with QT 6.2 and I added the rounded background and it give the same issue, but lower version this is not happen, I will report the Bug.

                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