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. Changing font size on active focus
Qt 6.11 is out! See what's new in the release blog

Changing font size on active focus

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 2.9k 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.
  • S Offline
    S Offline
    scarleton
    wrote on last edited by
    #1

    I am working on creating a custom TextInput control. Here is PART of it:

    @FocusScope {
    id: focusScope

    property int pointSize: 8;
    
    TextInput {
        id: textInput
        anchors { left: parent.left; leftMargin: 8; right: parent.right; rightMargin: 8; verticalCenter: parent.verticalCenter }
        font.pointSize: focusScope.pointSize
        focus: true        
        selectByMouse: true
    }
    
    states: [
        State {
            name: "hasFocus"; when: focusScope.activeFocus;
            PropertyChanges { target: textInput; font.pointSize: focusScope.pointSize + 4 }
        }
    ]
    

    }@

    The goal is to increase the font size by a point size of 4, but it isn't working. What am I doing wrong?

    Sam

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbrasser
      wrote on last edited by
      #2

      Hi,

      The above example gives me a point size of 12 when I click on the TextEdit and start typing. Is that what you are after? If so, it could be a case of a bug that has been already fixed (either in 4.7.1 or the upcoming 4.7.2). If not, could you describe more fully what you are after? Did you want it to increase by 4 each time it gains active focus (e.g. 12, 16, 20, etc.)?

      Regards,
      Michael

      1 Reply Last reply
      0
      • S Offline
        S Offline
        scarleton
        wrote on last edited by
        #3

        Very interesting, I am doing something like the qt\examples\declarative\ui-components\searchbox, so there is a Text element which is visible as long as the there is no text in the TextInput. When I added the property change to the Text element, it changed size, but the TextInput does not. I am running 4.7.1.

        1 Reply Last reply
        0
        • B Offline
          B Offline
          blam
          wrote on last edited by
          #4

          Hi, it would be easier to see the problem if you post some code here, to show how the bindings are created and how the objects respond to property changes.

          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