-
Notifications
You must be signed in to change notification settings - Fork 416
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
Control.parent
property
#952
Comments
Maybe it would make sense to add some functionality regarding children too while we're at it? In Qt there's a This would be useful for use cases like the one mentioned above when e.g. only some child controls fulfilling a certain condition should be removed from a list. |
|
.parent Yes that is needed. |
+1 |
Discussed in #950
Originally posted by ndonkoHenri January 29, 2023
@FeodorFitsner, what do you think of adding a way to access the parent of a control?
I thought of this idea because alot of guys have been asking how to delete an item from a
ListView
(ListTile
) when a button/Control in the tile is pressed.The way I solve this issue was to always add a reference to the tile in the
data
property of theControl
which will be used to delete the tile... and when the required event happens, grab thee.control.data
(the ref), andremove
it from theListView.controls
list. Nevertheless, I think a better, efficient, and alternative approach could be to access the parent of that Controle.control.parent
(the ref), andremove
it from theListView.controls
list.Why could this be useful?
Using references could become an issue or fail when the
Control
keeping that reference is moved elsewhere. Whereas, using the.parent
is cleaner and will never fail, because when theControl
we need is moved any where, it's.parent
is changed to its new parent.I maybe poorly explained my thoughts, but
.parent
could be used in many other areas.Let me know what you think of this.
I just had the idea, but don't even know if it will be possible to implement :)
The text was updated successfully, but these errors were encountered: