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] TextFieldStyle: Height of Rectangle does not correspond font size...
Forum Updated to NodeBB v4.3 + New Features

[solved] TextFieldStyle: Height of Rectangle does not correspond font size...

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

    I have a TextField and want to give it a custom style:

    @
    TextField
    {
    id: blah;
    anchors { left: test.right; top: test.top; }
    font { family: "Arial"; pointSize: 14; }
    style: TextFieldStyle
    {
    textColor: "#000";
    background: Rectangle
    {
    color: "#FFF";
    border.color: "#999";
    border.width: 1;
    radius: 4
    // implicitHeight: 100;
    // implicitHeight: blah.height;
    }
    }
    }
    @

    The Rectangle is supposed to be as large as the text in the TextField. However, this is not the case: The rectangle is apparently given a constant height, ignoring whatever font size is set in the TextField.

    If I set implicitHeight to some constant value, this'll work, but it obviously isn't what I'm looking for. If I set implicitHeight to the TextField's height, nothing happens (except that I saw an error complaining about anchor loop once.)

    How do you do this correctly?

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

      Hi,

      Above example works for me. Tested on Qt 5.3.1, Ubuntu 14.04
      @
      Rectangle {
      width: 300
      height: 300

      TextField
      {
          id: blah;
          font { family: "Arial"; pointSize: 32; }
          style: TextFieldStyle
          {
          textColor: "#000";
          background: Rectangle
          {
          color: "#FFF";
          border.color: "#999";
          border.width: 1;
          radius: 4
      }
      

      }
      }
      @

      157

      1 Reply Last reply
      0
      • D Offline
        D Offline
        digorydoo
        wrote on last edited by
        #3

        Strange... I'm testing this on Windows and on Android, and it doesn't work on either platform! Qt 5.3.0

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

          Can you try with Qt 5.3.1 ?

          157

          1 Reply Last reply
          0
          • D Offline
            D Offline
            digorydoo
            wrote on last edited by
            #5

            I'll check this as soon as I find the time. In the meantime, did you use these components:

            @
            import QtQuick.Controls 1.2
            import QtQuick.Controls.Styles 1.2
            @

            Or some newer version?

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

              Yes
              @
              import QtQuick 2.3
              import QtQuick.Controls 1.2
              import QtQuick.Controls.Styles 1.2
              @

              Also worked with
              @
              import QtQuick 2.0
              @

              157

              1 Reply Last reply
              0
              • D Offline
                D Offline
                digorydoo
                wrote on last edited by
                #7

                I've downloaded Qt 5.3.2, now the problem is gone!

                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