How to add a child widget to non-container widget?
Added by Richard Li over 11 years ago
As the title, if I want add a widget to a WText,or WFormWidget...What should I do?
There is no addWidget method in these class...
Replies (3)
RE: How to add a child widget to non-container widget? - Added by con abs over 11 years ago
Corresponding to my response, if you want to add a widget as a child of a WText or WFormWidget...I'm sorry you cannot.
For WText, wocai nee yaode is: WTemplate(http://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1WTemplate.html)
RE: How to add a child widget to non-container widget? - Added by Richard Li over 11 years ago
Thank you,I thought I can further describe my question.Althought maybe it seems not necessary.
The WTemplate I have used before,but it has no addWidget method.
So,for example,I must implement a unit like this:
<label>
<span>
<span />
<span />
</span>
<input type="checkbox">
</label>
I use WTemplate to implement it.
setTemplateText("<label> <span> ${sub-span1} ${sub-span2}</span> ${checkbox} ${text} </label>");
then bindWidget(),
and the question come out:the span or label is only a tag,not a widget,how can I obtain their event such as clicked() in Wt?
In another way,I implement like this:
setTemplateText("${span} ${checkbox} ${text}");
the span is a widget inherit by WContainerWidget,So I can use the clicked() signal and addWidget() method.
Maybe it's a solution,but still have a problem:if I defined a setDisabled() method,it will against the WContainerWidget's same function.I thought it is against the widget original designed idea.
So,only a suggestion,can add a addWidget() function to WTemplate in Wt?
RE: How to add a child widget to non-container widget? - Added by con abs over 11 years ago
You need one WTemplate and one WContanierWidget.
WTemplate: setTemplateText(" ${the-holy-container-widget} ");
then bind the WContainerWidget,
then WContainerWidget::addWidget what the [a-z]{4} you want.