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:
- 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.
- Create a
QTreeWidget or QTableWidget, in which the respective Items are connected to the EventedModel signals.
I see the following issues with these approaches:
- 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.
- 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!
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
EventedContainerholdingEventedModelinstances, I'd like those to be shown in aQTable[...]or even aQTree[...].Two approaches are feasible:
EventedContainerto aQAbstractItemModel. This could utilize the.internalPointer()function to return data directly from theEventedModel. Then you could use aQTreeVieworQTableViewto show the data from the Qt model.QTreeWidgetorQTableWidget, in which the respective Items are connected to the EventedModel signals.I see the following issues with these approaches:
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!