pyQt How do I get a widget from a QListWidgetItem?
-
hi All
I have used setItemWidget() to put a custom widget in a QListWidgetItem, how do I get a reference to it afterwards?
Also, related question- my QListWidget is no longer responding to mouse events etc. But it's easy to get mouse events from the custom widget. Is there a way of adapting the QListWidget to use its standard functions such as currentItem()? Or would teh normal process be to connect signals in the custom QWidget to slots in the GUI?
-
hi All
I have used setItemWidget() to put a custom widget in a QListWidgetItem, how do I get a reference to it afterwards?
Also, related question- my QListWidget is no longer responding to mouse events etc. But it's easy to get mouse events from the custom widget. Is there a way of adapting the QListWidget to use its standard functions such as currentItem()? Or would teh normal process be to connect signals in the custom QWidget to slots in the GUI?
There is a corresponding function
QWidget * itemWidget(QListWidgetItem *item) const
that you should be able to use.-Michael.
-
There is a corresponding function
QWidget * itemWidget(QListWidgetItem *item) const
that you should be able to use.-Michael.
@m.sue Great thanks! Do you know why the QListWidget no longer detects mouse events over the QListWidgetitem?
-
Hi,
That's because you put a widget in it which means it's that widget that will get the events.