Using container with content inside tab WTabWidget
Added by Oleg Orlov over 4 years ago
I am sorry for poor English and knowledge of C
I need to create Tabwidget interface and a set of some forms inside each Tab
The following code compiles successfully but the tab "first tab" is empty, the second and third displays the expected content
auto p = std :: make_unique <Wt :: WContainerWidget>;
auto layout = std :: make_unique <Wt :: WVBoxLayout> ();
layout-> addWidget (std :: make_unique <Wt :: WText> ( "One"));
layout-> addWidget (std :: make_unique <Wt :: WText> ( "Two"));
layout-> addWidget (std :: make_unique <Wt :: WText> ( "Three"));
layout-> addWidget (std :: make_unique <Wt :: WText> ( "Four"));
p () -> setLayout (std :: move (layout));
auto t1 = main_menu-> addTab (p (), "first tab");
auto t2 = main_menu-> addTab (std :: make_unique <Wt :: WText> ( "something 2"), "second tab");
auto t3 = main_menu-> addTab (std :: make_unique <Wt :: WText> ( "something 3"), "third tab");
where is the problem ?
Replies (1)
RE: Using container with content inside tab WTabWidget - Added by lm at over 4 years ago
auto p = std :: make_unique <Wt :: WContainerWidget>;
is illegal I think. std::make_unique
is a function so you must call it:
auto p = std :: make_unique <Wt :: WContainerWidget>();
Given that adjustment,
p () -> setLayout (std :: move (layout));
I believe is also illegal. You can't invoke (operator ()
) on a pointer like that. Perhaps you meant p->setLayout(std::move(layout));
?
auto t1 = main_menu-> addTab (p (), "first tab");
It almost looks like you meant for p
to be an alias for std::make_unique
and you're calling it several times? If that's what's happening (and my knowledge of C does not suggest that would be legal like this), you're creating several containers and probably leaking them.