Results 1 to 5 of 5

Thread: QWidget findChildren shows non existing childs

  1. #1
    Join Date
    Sep 2014
    Posts
    18
    Thanks
    2
    Qt products
    Platforms
    Unix/X11 Windows

    Question QWidget findChildren shows non existing childs

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QWidget findChildren shows non existing childs

    Quote Originally Posted by Goodwin View Post
    Why findChildren didn't remove a non-existing child objects?
    It does only find existing objects.

    close() doesn't remove a widget.

    Cheers,
    _

  3. #3
    Join Date
    Sep 2014
    Posts
    18
    Thanks
    2
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: QWidget findChildren shows non existing childs

    So how can I close widget and ?destroy? it?

  4. #4
    Join Date
    Jun 2015
    Location
    India
    Posts
    185
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QWidget findChildren shows non existing childs

    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.
    Thanks :-)

  5. #5
    Join Date
    Sep 2014
    Posts
    18
    Thanks
    2
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: QWidget findChildren shows non existing childs

    Thanks a lot for your help.
    I'm self-taught, and I was not familiar with this option.
    Thanks man

Similar Threads

  1. QLineEdit shows always the end, how shows start ?
    By Alundra in forum Qt Programming
    Replies: 8
    Last Post: 19th June 2015, 12:09
  2. Replies: 1
    Last Post: 22nd February 2012, 13:55
  3. Replies: 2
    Last Post: 25th November 2011, 00:47
  4. findChildren<QwtPlot *>()
    By gib in forum Qwt
    Replies: 0
    Last Post: 23rd March 2010, 03:09
  5. QObject::findChildren
    By TheKedge in forum Qt Programming
    Replies: 2
    Last Post: 2nd March 2006, 10:34

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.