Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. When is it issued (emit) the QListWidget::itemChanged(...) signal?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 2.8k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    isaacEnrique
    wrote on last edited by
    #1

    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

    Isaac Pérez
    Programming is understanding.

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      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

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      I 1 Reply Last reply
      0
      • GrzegorzG Offline
        GrzegorzG Offline
        Grzegorz
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • VRoninV VRonin

          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

          I Offline
          I Offline
          isaacEnrique
          wrote on last edited by
          #4

          @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?

          Isaac Pérez
          Programming is understanding.

          VRoninV 1 Reply Last reply
          0
          • I isaacEnrique

            @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?

            VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #5

            @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

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              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.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved