Skip to content

TreeView/TableView/ListView in conjuction with psygnal EventedDataclass/EventedModel #255

@ndxmrb

Description

@ndxmrb

Hi all,
I wasn't sure where to place this question (which might lead to a feature request?), but because of #77 I now decided to go ahead here:

If I had a psygnal EventedContainer holding EventedModel instances, I'd like those to be shown in a QTable[...] or even a QTree[...].
Two approaches are feasible:

  1. Create a ModelMapper that maps the EventedContainer to a QAbstractItemModel. This could utilize the .internalPointer() function to return data directly from the EventedModel. Then you could use a QTreeView or QTableView to show the data from the Qt model.
  2. Create a QTreeWidget or QTableWidget, in which the respective Items are connected to the EventedModel signals.

I see the following issues with these approaches:

  1. Maybe you could move the entire EventedModel to a separate thread, such that data operations always run there and never in the GUI thread. Maybe the Qt model approach prohibits that because of the pointer to the data? It's stated multiple times in Qt forums that you should never ever touch model data from outside the GUI thread.
  2. Probably this needs reimplementation of all the neat things Qt already provides in the model/view classes. But as it copies data rather than referencing it, data exchange via signals between threads is possible as it is the recommended approach.

Which implementation should be chosen here? Regarding the threading, I fear approach 2. could still run into race conditions on read/write enabled items (but isn't that the case for magicgui widgets, too?)...

Again, #77 leaves this intentionally vague, so this might be the starting point.

I tried to provide some (ever so small) value in addition to my question, but if it still is too forumy-questiony, feel free to close this 😋

Thanks for having a look though!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions