Project

General

Profile

Sharing a WTableView across WContainerWidgets

Added by David Betz over 10 years ago

I have a WStackedWidget. Many of the different layers of WStackedWidget display a WTreeView based on a common WStandardItemModel.

My present solution is to share a WStandardItemModel among the different layers of WStackedWidget, and have each layer of the WStackedWidget have it's own WTreeView. So I have one WStandardItemModel, with multiple identical WTreeViews displaying this model.

This has some disadvantages in that when a node is opened on the WTreeView, the other WTreeViews do not have their corresponding node opened unless I add some extra glue. Scrolling may also not be synchronized between the different WTreeViews.

So I was wondering - has anyone shared a WTreeView (or other complex widget) among multiple other widgets? How do you coordinate the destruction of the shared widget? Is there a paradigm for doing this?

I was thinking that I could use a WContainerWidget on each layer of the WStackedWidget, and every time a new layer is displayed, I call WContainerWidget~~removeWidget() on the old hidden layer, followed by a WContainerWidget~~>insert on the new show'd layer (actually, I will have to insert into a layout belonging to the WContainerWidget). Has anyone done this? Any pitfalls I'm not anticipating before I go off on this detour?


Replies (2)

RE: Sharing a WTableView across WContainerWidgets - Added by Koen Deforche over 10 years ago

Hey,

A widget can have only one parent. There is no way that can work since the id's that are used to synchronize between widget and DOM representation must be unique within the browser DOM.

There is thus no other (more practical) solution than implementing the necessary 'glue' code.

Regards,

koen

RE: Sharing a WTableView across WContainerWidgets - Added by David Betz over 10 years ago

I guess, Koen, that what I was wondering about is if I could reparent a WTreeView to the new layer each time a new layer is shown in a WStackedWidget. The WTreeView would still only have one parent, but that parent would change through time as different layers of the stack are shown.

I am guessing that this might involve the transfer of large amounts of data every time the WTreeView was reparented to a new layer in a WStackedWidget.

    (1-2/2)