Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QML Dynamic Focus
Forum Updated to NodeBB v4.3 + New Features

QML Dynamic Focus

Scheduled Pinned Locked Moved Solved Mobile and Embedded
5 Posts 2 Posters 1.6k 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.
  • G Offline
    G Offline
    geageagea
    wrote on last edited by
    #1

    Hi, I'm working in an application running under an embedded linux device. It
    is a complex application that has many QML components which are created and
    destroyed when necessary. The user interface is the touchscreen and 4 buttons
    accessible through standard GPIO's. What I need to achieve is to change focus
    "dynamically" between all the present components, without having to
    modify every qml document (if it is possible), when a button is pressed. Each
    button has a dedicated signal that the root qml component (ApplicationWindow)
    receives. I'm aware of the FocusScope implementation but I wanted to know if
    there is some mechanism to access all the root's children and their
    properties. Thanks in advanced. Best regards

    p3c0P 1 Reply Last reply
    0
    • G geageagea

      Hi, I'm working in an application running under an embedded linux device. It
      is a complex application that has many QML components which are created and
      destroyed when necessary. The user interface is the touchscreen and 4 buttons
      accessible through standard GPIO's. What I need to achieve is to change focus
      "dynamically" between all the present components, without having to
      modify every qml document (if it is possible), when a button is pressed. Each
      button has a dedicated signal that the root qml component (ApplicationWindow)
      receives. I'm aware of the FocusScope implementation but I wanted to know if
      there is some mechanism to access all the root's children and their
      properties. Thanks in advanced. Best regards

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi @geageagea,

      What I need to achieve is to change focus
      "dynamically" between all the present components, without having to
      modify every qml document (if it is possible), when a button is pressed.

      Yes you can set focus property of those component to true when required.

      ... but I wanted to know if
      there is some mechanism to access all the root's children and their
      properties.

      One way to access children properties is to create an alias in parent and which is binded to the individual children.

      May be I have not completely understood your question. Can you narrow it down and provide a sample code or some sort of representation of what you are trying to achieve ?

      157

      1 Reply Last reply
      0
      • G Offline
        G Offline
        geageagea
        wrote on last edited by
        #3

        Hi @p3c0,
        Thanks for your response. Sorry if I can't make myself clear but English is not my native language. My application has many QML components and recently I've been requested to implement these function keys (simple buttons attached to GPIOs) as navigation keys. There are 3 keys: up, down and enter. Pressing up or down should highlight the next or the previous element on the screen and pressing enter should simulate the click. So I was wandering if it is possible to access to every child recursively through a simple function. I can't figure it out how would I do it but that would be the idea. Doing this, I want to avoid modifying every single element in the project.

        p3c0P 1 Reply Last reply
        0
        • G geageagea

          Hi @p3c0,
          Thanks for your response. Sorry if I can't make myself clear but English is not my native language. My application has many QML components and recently I've been requested to implement these function keys (simple buttons attached to GPIOs) as navigation keys. There are 3 keys: up, down and enter. Pressing up or down should highlight the next or the previous element on the screen and pressing enter should simulate the click. So I was wandering if it is possible to access to every child recursively through a simple function. I can't figure it out how would I do it but that would be the idea. Doing this, I want to avoid modifying every single element in the project.

          p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          @geageagea

          So I was wandering if it is possible to access to every child recursively through a simple function.

          Use children property to iterate over all children of parent Item.
          Eg.

          for(var i=0; i<root.children.length; i++)
               console.log(children[i])
          

          157

          1 Reply Last reply
          0
          • G Offline
            G Offline
            geageagea
            wrote on last edited by
            #5

            Hi @p3c0
            Sorry for keeping you waiting (?) but I was working on another things. I have tried what you said but the element ApplicationWIndow has no property children. On console, whenever I access to root.children.length (root is the id of my ApplicationWIndow) it says

            "TypeError: Cannot read property 'length' of undefined"
            

            So, I keep looking and I found out that instead of the children property I have to use the contentItem property and it works.
            Thanks a lot for the help
            Best regards
            Gustavo

            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