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. [SOLVED ] Using (empty) TextFieldStyle alters size of the TextField
Forum Updated to NodeBB v4.3 + New Features

[SOLVED ] Using (empty) TextFieldStyle alters size of the TextField

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 2 Posters 1.4k 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.
  • K Offline
    K Offline
    Kieren
    wrote on last edited by
    #1

    Hi,
    if searched quit ab bit for this but haven't found anything about it,
    so here is my problem

    I'm working on a Login-Screen and encountered a strange behavior when using TextFieldStyle.
    As soon as I use TextFieldStyle the size of the TextField is changed.
    Especially annoying is the fact that the height is increased by seemingly 5 pixels and so the TextField looks just to big for the text it contains.

    I'm not sure if this is intended or not.
    And before I start setting sizes manually I'll just ask if I'm doing something wrong here?

    What I was hoping to accomplish is, that the TextField "height" changes with the used font size automatically.

    Here is a working example of this Problem:
    The height of the TextFields is shown as placeholderText so you don't need to count pixels :)
    @
    import QtQuick 2.2
    import QtQuick.Controls 1.2
    import QtQuick.Controls.Styles 1.2
    import QtQuick.Layouts 1.1

    ApplicationWindow {
    id: loginRequest
    visible: true
    title: "Login"
    width: 250
    height: 150

    Item {
    anchors { left: parent.left; right: parent.right; top: parent.top }
    anchors.margins: 15
    ColumnLayout {
    id: column
    spacing: 15

      RowLayout {         
        Text {
          text: "Account name:"
        } 
    
        TextField {
          id: accountNameTextField
          placeholderText:  accountNameTextField.height
        } 
      } //RowLayout
    
      RowLayout {
        Text {
          text: "Password:"
        }
        
        TextField {
          id: passwordTextField
          placeholderText:  passwordTextField.height
          //echoMode: TextInput.Password
          style: TextFieldStyle{} //<== here the problem line
        } 
      } //RowLayout
    }//ColumnLayout
    

    }//Item
    } // ApplicationWindow
    @

    Thank you all
    Cheers
    Kieren

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      Not sure. But it could be bug in default Desktop Style.
      Try exporting QT_QUICK_CONTROLS_STYLE=Base. It displays correctly.

      157

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Kieren
        wrote on last edited by
        #3

        Hi,
        thanks for your replay.
        So the QT_QUICK_CONTROLS_STYLE=Base does influence the appearance, but exactly in the different direction of what I want :/

        With QT_QUICK_CONTROLS_STYLE=Base both TextField look the same, sadly both are 20+5 pix hight.

        Now as you pointed me in the right direction I found the problematic style parts in the TextFieldStyle.qml delivered by Qt:

        Desktop:
        @contentHeight: Math.max(control.__contentHeight, 16)@
        Base:
        @backgroundLoader.implicitHeight || Math.max(25, Math.round(control.__contentHeight * 1.2))@

        Looks like i can not do anything bout this problem while using default style.
        It's just confusing that it still take some parts of the default/base style if I use my own style.
        Might be that I just create a copy of these styles and than overwrite some parts?

        Still the question if this looks like intended behavior or not?

        I'll discus with my team how we'll address this problem.

        Thanks.
        Cheers,
        Kieren

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          Unfortunately I too haven't explore the details of these styles. I would suggest you to put this question on "Qt Interest Mailing List":http://lists.qt-project.org/mailman/listinfo/interest. You might get the proper way from the Qt Developers directly.

          157

          1 Reply Last reply
          0
          • K Offline
            K Offline
            Kieren
            wrote on last edited by
            #5

            I marked the tread as SOLVED, as the problem is now understand.

            Would still be interesting to know if this behavior s intended or not,
            might be the Mailing List will answer this.

            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