cbpporter Messages: 1427 Registered: September 2007
Ultimate Contributor
normvcr wrote on Sat, 31 October 2015 11:46
The examples I have seen show menus and toolbars as data members of top-level windows. Can a top-level window be created with menus and toolbars, without being pre-defined as a class with these objects as data members? i.e. something like this:
window = new Window;
window->add( new Menu );
Thank you
Sure, it can. But it is an inferior approach with no benefits and only disadvantages. You loose the ability to refer to a widget at a random point in time if you do not have a member to store it. And if you do want a member to store it, not using pointer removes the need to do manual memory management.
The only scenario I can think of is when you wish to load an interface from an external file, like and XML file. There is a sample if I am not mistaken which loads GUI from and XML file.