Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » Dynamic windows & widgets (How to construct windows with widgets, other than by inheritance)
Dynamic windows & widgets [message #45332] Sat, 31 October 2015 10:46 Go to next message
normvcr is currently offline  normvcr
Messages: 5
Registered: October 2015
Promising Member
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
Re: Dynamic windows & widgets [message #45348 is a reply to message #45332] Sat, 31 October 2015 19:26 Go to previous messageGo to next message
cbpporter is currently offline  cbpporter
Messages: 1401
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.
Re: Dynamic windows & widgets [message #45358 is a reply to message #45348] Sun, 01 November 2015 18:20 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
http://www.ultimatepp.org/reference$DynamicDlg$en-us.html

Note that even in this case, recommended U++ approach is to avoid 'new'/'delete' and use Array and in-place creation.
Previous Topic: Fedora 22 prerequisites
Next Topic: Help: GetSysTime()
Goto Forum:
  


Current Time: Tue Apr 16 19:49:35 CEST 2024

Total time taken to generate the page: 0.02713 seconds