PDA

View Full Version : What happened when Qt Widget SetParent(NULL)



familymrfan
22nd October 2013, 04:48
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!

wysota
22nd October 2013, 06:54
Setting a null parent makes a widget a top-level window.