Hi to all,
I know that when I create a new widget ( for example a QPushButton ) I need to pass the parent widget to the ctor, so the new created widget can be deleted when the parent is deleted.
What is not so clear for me is ( looking at the documentation ) is why the parent is not passed to the widget when it's added to a layout.
for example this code:
Qt Code:
layout->addWidget(button1); layout->addWidget(button2); layout->addWidget(button3); layout->addWidget(button4); layout->addWidget(button5); window->setLayout(layout); window->show();To copy to clipboard, switch view to plain text mode
is part of the QVBoxLayout documentation.
I can not see where the parent widget is passed to the buttons and layout. Does it generate memory leaks errors?
Maybe is my mistake or maybe the Qt developers doen't give much attention to the examples, it this last case it would be better that Qt developers post correct code without errors.
Best Regards
Bookmarks