Dynamically create tabs in WDTabWidget
A layout and widget editor for Wt (C++ web applications)
Brought to you by:
eoinmcmahon,
nigellea
Hello, I tried to create a tree structure using multiple file dwo. In the main file there are three containers: top container that contains menu, bottom container containing status bar and finally middle container (wdtabwidget) in which I have to dynamically create tabs. The only way to show the content of the new tab is:
Newtab *NewmyTab = new Newtab();
main_one->MiddleContainer->addTab(Newmytab->top,"Description",false);
main_one->MiddleContainer->setCurrentWidget(Newmytab->top);
but the sizes of the new generated tab are not congruent with the sizes of the container.
I tried to create a new WDSContainerWidgets and then create the new Tab setting the parent to it and then adding this container as tab of the MiddleContainer, but the new tab does not contain anything.
If I try to add not Newmytab->top but directly the Newmytab as new tab, the Newmytab overwrites the wdtabwidget.
Have you any suggestion?
thanks
Last edit: Acacia 2015-06-04
Hello Acacia
Your problem has revealed a deficiency in WDTabWidget, it is not easy to attach a design to a newly created tab. We hope to correct this in the next release of DesignerWt.
As it is easy to attach a design to an existing (container) tab (one created in DesignerWt), then you could consider creating several container tabs in MiddleContainer and using the setTabHidden method of WDTabWidget to hide the tabs not in use.
Otherwise you could use the code given below. This dynamically adds to the layout structure of the main_one design to create a new container tab. The second design is then attached to this tab.
I hope that one of these approaches will prove to be an acceptable workaround until the next release of DesignerWt.
Regards
Nigel
Thank you. I've tried both the solutions. But only the first one is working. The second one opens a new tab but it is empty. However I've another question about the popup menu related to their colours and formatting. It always appear a small circle on the left of all items with different background colour and without the arrow on the right side for the submenus. This behaviour does not appear whenever I do the preview by the designer.
Thank you.
Lorenzo
Lorenzo
I'm suprised that the second solution didn't work. Possibly you are not adding the tab in the session constructor, in which case you will need to do
after attaching the second design.
If you still have a problem then perhaps you could attach designs (.dwo's) and source code to a post so that I can diagnose the problem.
I haven't seen the problem with popup menus that you describe. Does this behaviour happen with the popup menu in Example1? Again I am happy to investigate further if you supply a design file.
Regards
Nigel