Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Find by unique object name. #44

Closed
mmjvox opened this issue Nov 13, 2021 · 2 comments
Closed

Find by unique object name. #44

mmjvox opened this issue Nov 13, 2021 · 2 comments

Comments

@mmjvox
Copy link

mmjvox commented Nov 13, 2021

Hi dear @faaxm
Thanks for creation of this useful and beautiful thing. ❤️ 👍 🌹
How to find items by a unique object name.
It is really hard to access to an item by its full path. ("mainWidnow/mainView/rightSide/setting")
I have some items that are creating by another ones in runtime Unpredictably and they don't have any predefined area.
I don't now to handle some situations like this.
But if there is a way to access qml items by unique object name i think this problem will be solved easily.

@faaxm
Copy link
Owner

faaxm commented Nov 13, 2021

Hi @mmjvox ,
spix is actually not so picky about the correct path and it can still find an item even if you skip some components in the path.
I.e. as long as there is no ambiguity, mainWindow/setting should lead to the same item as mainWindow/mainView/rightSide/setting. This is probably something that should be documented better... 😅

Basically spix just goes through all child items and looks for one that has the name of the next path component, but it will actually also search through the children of the child items until something is found with the right name...

The code that recursively resolves the path is here:

QQuickItem* getQQuickItemWithRoot(const spix::ItemPath& path, QObject* root)

and the code that finds one particular child item by name (and also traverses further down if nothing is found) is here:
QObject* FindChildItem(QObject* object, const QString& name)

@mmjvox
Copy link
Author

mmjvox commented Nov 14, 2021

Thanks a lot.

@mmjvox mmjvox closed this as completed Nov 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants