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. Determining focus
Forum Updated to NodeBB v4.3 + New Features

Determining focus

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.3k 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 trying to modify the "search box":http://doc.qt.nokia.com/4.7/declarative-ui-components-searchbox.html example to be a simple edit box. The goal is to make the border "highlight" when it gains focus, not when text is typed. I tried adding id's to the borders and added the following State, but it doesn't work:

    @
    BorderImage {
    id: normalBorder;
    source: "images/lineedit-bg.png"
    width: parent.width; height: parent.height
    border { left: 4; top: 4; right: 4; bottom: 4 }
    }

    BorderImage {
        id: focusBorder;
        source: "images/lineedit-bg-focus.png"
        width: parent.width; height: parent.height
        border { left: 4; top: 4; right: 4; bottom: 4 }
        opacity: 0
    }
    
    states: [
        State {
            name: "hasFocus"; when: focusScope.focus
            PropertyChanges { target: normalBorder; opacity: 0 }
            PropertyChanges { target: focusBorder; opacity: 1 }
        }
    ]
    

    @

    Any thoughts?

    [EDIT: fixed formatting, pleas use @-Tags, Volker]

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

      Hi,

      You might need to change when: focusScope.focus to when: focusScope.activeFocus. (activeFocus roughly corresponds to the traditional Qt C++ definition of having focus; http://doc.qt.nokia.com/4.7-snapshot/qdeclarativefocus.html has more details)

      Regards,
      Michael

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

        That worked like a charm, thank you!

        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