When is it issued (emit) the QListWidget::itemChanged(...) signal?



  • Regards

    Consider the following case:
    I have a GUI application. Among the GUI widgets is a QListWidget.

    I have a custom class, say MyCustIt.

    For each item in the QListWidget, I use QListWidgetItem::setData(...) to set the item data to be a pointer to a object of type MyCustIt (i.e MyCustIt*)

    Doubt/question:
    Is the signal QListWidget::itemChanged(...) issued (emit) if any of the object mentioned above (MyCustIt objects) change something (e.g, change some of its data members)?

    Thanks in advance for any responses and/or comments



  • Short answer: no.
    QListWidget has no way of knowing the internal memebrs of MyCustIt so it cannot react to them unless you explicitly ask it to connecting signals from MyCustIt



  • Dear Isaac,

    The signal itemChanged () signal is emitted if the selection of an item is changed – a new item become the current one. If you would like to control changes to a member of an item’s object you have to emit a signal – probably defined by your own – from that object. The signal shall be received in the class that wraps the QListItem (owner or successor).

    On the other hand, it would be easier to you to handle items if the class of items would have been QVariant compatible.

    Good luck, Grzegorz



  • @VRonin Particularly, the object of which I speak (MyCustIt) is a subclass of QGraphicsItem.

    In case you change the selection status of the object (not selected to selected, and vice versa), the signal QListWidget::itemChanged(...) is issued?



  • @isaacEnrique Regardless of the class, setData will never link the model to the internals of the object automatically (if you want to achieve this, you have to connect them manually). Changing the selection will not trigger a QListWidget::itemChanged but will trigger a QItemSelectionModel::selectionChanged from QListWidget::selectionModel


  • Lifetime Qt Champion

    Hi,

    To add to my fellow, if you want to react on such a change, you should consider implementing your own list model based on QAbsractListModel and use QListView.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.