Changing font size on active focus

  • 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?


  • 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.)?


  • 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.

  • 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.

Log in to reply