Question: how to enumerate all components to create the element tree? #1882
-
Hi, we need to find all box and buttons on a Slint window but cannot find effective ways to do that. Any advice? For examples, the following window has 3 buttons, each button has a text.
How to get something similar to an element tree:
Just like the "inspector" tool in Windows. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hi @threefoldo , I took the liberty to convert the issue into a discussion, which is better suited for such questions. Do you mean to get this information in a GUI of your editor? Or programmatically? If as part of the GUI, this would be the outline view (in vscode for example) |
Beta Was this translation helpful? Give feedback.
-
Thanks for your quick reply. Yes, I want to get all properties and parent-child relations of components inside a window programmatically. The following picture is a screenshot of inspect.exe, which show the element tree of all controls. You can navigate from the root node to any control in the window. It's similar to the properties and outline tab in slint-editor, however, I found that the editor doesn't query all the information from the root node, i.e., the Window object, but only parse the .slint file. If one component, for example, a non-standard Button, was defined in another .slint file, then the outline will not show its information. That's different from the way of inspect.exe. Our goal is to create various UI windows programmatically, so we need to know the position and size of all components (including layout, widgets), then the program can decide whether or not to add more widgets, and where to place them. |
Beta Was this translation helpful? Give feedback.
-
5fca344 is a patch I sometimes use (not updated in a while though!) to print a dot file of the item tree in Slint. That is way more low-level than the tree of elements you are looking for though, I do still find it interesting to look at sometimes :-) That's an older version of the generated output. The patch dumps text in |
Beta Was this translation helpful? Give feedback.
5fca344 is a patch I sometimes use (not updated in a while though!) to print a dot file of the item tree in Slint.
That is way more low-level than the tree of elements you are looking for though, I do still find it interesting to look at sometimes :-)
That's an older version of the generated output. The patch dumps text in
dot
syntax, which you can render to svg, png or whatever using the graphviz package.