Home » U++ Library support » TabCtrl » How to dynamically add remove tabs
How to dynamically add remove tabs [message #60184] |
Mon, 25 September 2023 20:20 |
nicesai
Messages: 2 Registered: September 2023
|
Junior Member |
|
|
I am doing something like this:
void addTab() {
WithTabLay<ParentCtrl> *tabLay = new WithTabLay<ParentCtrl>();
CtrlLayout(*tabLay);
tabLay->HSizePosZ(0, 0).VSizePosZ(0, 0);
tabs.Add(*tabLay, MyImgs::add20(), "Tab1");
tabLay->closeBut.WhenPush = [=] {
tabs.Remove(*tabLay);
tabLay->~WithTabLay();
delete tabLay;
};
}
As you can guess,
WithTabLay is the tab layout created in the UI editor.
closeBut is a button within the tab that I want to use to remove the tab.
Question-1: Is it necessary to call the destructor after removing the tab?
tabLay->~WithTabLay();
Question-2: Is it necessary to delete the allocated memory? This line causes the applicatton to crash. So probably I should not, if so, how can I free the allocated memory?
delete tabLay;
Questions-3: Is there any better way to do this without using pointers? If I create the Tab on stack, its free'ed at the end of the function (from RAII I suppose). And the Tab will not be visible.
|
|
|
Goto Forum:
Current Time: Mon May 13 05:37:47 CEST 2024
Total time taken to generate the page: 0.05102 seconds
|