PDA

View Full Version : Interaction with a widget that is rendered to display data in a model



yetien
20th August 2010, 22:41
Hi!

I've got a custom model and a custom delegate. The delegate (for Qt.DisplayRole) instantiates a widget with a label and a button. See the attached screenshot for visualization: 5091

If the widget is shown f.ex. in a listview I cannot press the button. Is there a way that I can interact with a control on the widget if it is not shown in edit-mode?

The other attachment is a show case for the issue in PyQt code: 5092

Thanks in advance!

yetien
21st August 2010, 09:34
Solved, thanks. The trick is to use QAbstractItemView.openPersistentEditor(index) as render just gives the pixmaps of the widget without functionality. So one has to implement the createEditor and an empty setModelData method in the delegate.
However, if one does that for many items it gets slow. For me it doesn't matter since I anyway just wanted the button to show up if the mouse hovers over it, so its just one persistent editor