PDA

View Full Version : QWidget findChildren shows non existing childs



Goodwin
2nd September 2015, 14:14
Hi!
I need to catch if child widget is open and I use findChildren from parent.
In first loop, after child widget is initialized in 1 time - I find it with findChildren, and it's ok.
But after closing child widget with close() - the findChildren still shows child object in generated list.
After open child widget in 2 time findChildren shows two copies of child objects.
How findChildren works?
Why findChildren didn't remove a non-existing child objects?

anda_skoa
2nd September 2015, 14:30
Why findChildren didn't remove a non-existing child objects?
It does only find existing objects.

close() doesn't remove a widget.

Cheers,
_

Goodwin
2nd September 2015, 14:49
So how can I close widget and ?destroy? it?

prasad_N
2nd September 2015, 15:31
you can set Qt::WA_DeleteOnClose property to the widget (child). then widget will be deleted when it is closed.

or if you still want to use the object & do not want to delete it on close. you can use QWidget::isvisible() after you find children to make sure it has close or not.

Goodwin
2nd September 2015, 19:37
Thanks a lot for your help.
I'm self-taught, and I was not familiar with this option.
Thanks man