Wt3.2.2 - WGridLayout->addWidget does not work as expected
Added by Michael Leitman over 12 years ago
Hello :)
I just covered a problem with adding content (Widgets) to a WGridLayout during runtime:
If my application starts and calls createUI()
it creates a WContainerWidget and gives it a Layout:
WContainerWidget *container = new WContainerWidget();
WGridLayout *contLayout;
container->setLayout(contLayout);
// add default content
contLayout->addWidget(new WContainerWidget(), 0, 0);
Because this content is depening on selected stuff by the user,
i tried to update it during runtime calling:
contLayout->addWidget(new WContainerWidget(), 0, 0);
This should just replace the current widget in the Layout, as the documentation under:
http://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1WGridLayout.html#a6e64afee237de5665fcd014f407130b2
says: Adds the widget at (row, column). If an item was already added to that location, it is replaced (but not deleted).
This works in wt3.2.1, but in 3.2.2 not.
As i found out, the actual widget in the Layout is removed,
but the new one is not inserted in the Layout (as resulting table in html) but "outside".
Pseudocode for the resulting generated html:
After creating UI for the first time
<div> // container
<div> // relativ container
<table>
<colgroup>...<colgroup>
<tbody>
<tr><td>
<div> /*this is the actual WContainerWidget inserted to the Layout*/ </div>
</td></tr> // ... etc... depending on Layout Row/Column Count
</tbody>
</table>
</div>
</div>
With Wt3.2.1 everytime i call "layout->addWidget()" on the same Row/Column the current widget is removed, and the new inserted,
the html looks as above and just the inner div changes.
But using Wt3.2.2, the resulting html after "reinserting" an Widget to the same Row/Col looks the following:
<div> // container
<div> // relativ container
<table>
<colgroup>...<colgroup>
<tbody>
<tr><td></td></tr> // --> empty where the inner div should be
</tbody>
</table>
<div>/*this is the actual WContainerWidget inserted to the Layout*/</div>
<div>/*everytime i call addWidget()*/</div>
<div>/*another div is inserted with the same id and all other properties*/</div>
</div>
</div>
If i dont use progressive bootstrap, the
elements are gone,
but the effect is still the same:
there are the same div added and added again everytime i call addWidget.
I know, i should better use a WStackedWidget, which is most suitable for exactly this usage,
but i think this could be the same bug for changing "setColumnResizable(col, bool)" during runtime
as i mentioned already here: http://redmine.webtoolkit.eu/boards/2/topics/4394#message-4395
best regards and thanks for any help
- the incredible Leitman
Replies (1)
RE: Wt3.2.2 - WGridLayout->addWidget does not work as expected - Added by Koen Deforche over 12 years ago
Hey,
I've fixed this in my git copy, and this will be part of a new RC (which might be the final 3.2.2?) which I intend to push out today.
With progressive bootstrap mode, this will indeed not work (as is indicated in WGridLayout documentation).
Regards,
koen