Results 1 to 2 of 2

Thread: What happened when Qt Widget SetParent(NULL)

  1. #1
    Join Date
    Oct 2013
    Posts
    1
    Qt products
    Qt5

    Default What happened when Qt Widget SetParent(NULL)

    here is my code:

    QPushButton* button = new QPushButton;
    button.setParent(&window); // button appear on window
    button.setParent(NULL); // button disappear on window
    button.setParent(&window); // button appear on window again

    when I setParent(&window) again, I realize that the button were not release by setParent(NULL).

    My question is, if I not setParent(&window) again, when button release himself, now it leave from his parent!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: What happened when Qt Widget SetParent(NULL)

    Setting a null parent makes a widget a top-level window.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. QObject::setParent across threads.
    By psih128 in forum Qt Programming
    Replies: 4
    Last Post: 21st January 2014, 16:01
  2. hwnd to qwidget setparent error
    By cic in forum Qwt
    Replies: 1
    Last Post: 27th August 2013, 14:40
  3. What happened to Qt?
    By Plissken in forum General Discussion
    Replies: 1
    Last Post: 28th September 2012, 22:52
  4. What happened???
    By Archa4 in forum Newbie
    Replies: 2
    Last Post: 21st February 2011, 07:37
  5. Qt widget setParent
    By bunjee in forum Qt Programming
    Replies: 9
    Last Post: 30th November 2007, 20:38

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.