Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-70831

Create a checkStateChanged for QListWidgets & QTableWidgets and/or their items; or make other signal reliable

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Won't Do
    • P2: Important
    • None
    • 5.10.1
    • Widgets: Itemviews
    • None
    • Win 7 SP1 32-bit

      Qt 5.10.1

      Qt Creator 4.6.2

      MSVS Community Edition 2015 C++ toolchain

    • All

    Description

      I would like to be able to set some variables when an item in a QListWidget has its checkState change.  Unfortunately, none of the existing signals fire reliably for this event.  At first, I was using itemChanged, but defining a slot for itemChanged, one of for itemClicked, for itemPressed and for QAbstractItemView, and printing with qDebug() in each, showed that if I activated one and toggled the check on and off, a number of these signals fired just fine.  However, if I restarted the application, and just went to the square for the checkmark, and clicked it, without otherwise interacting with the item, the check would appear, but none of the events fired.  It is my conclusion that there is no reliable signal for this event.

      This is also the conclusion of the following StackOverflow question:

      "Qt/C++: Signal for when a QListWidgetItem is checked?"

      http://stackoverflow.com/questions/4252935/qt-c-signal-for-when-a-qlistwidgetitem-is-checked

      It is not hard for me to simply record which items are checked in one QListWidget, once I am prepared to use them; but I have a situation where selecting items that are checkable in one QListWidget brings up items in another; which are also checkable, and whose states must also be saved and recalled for editing.  This is getting less convenient; since I'll have to save their values from more than one place.  More to the point, it seems like one of these other events ought to catch it, but none do - so as things are, anyone trying to have something happen as a result of checking an item, will probably have to try one signal, then others, then search on StackOverflow, and then completely re-think the strategy for saving them.  This seems like a long way around, for something that should be simple, and it seems like an oversight in the API.

      While one can do it with a QListView, QListWidget is supposed to be a convenience class.  This would make it more convenient for those using items which are checkable.  My problem concerned QListWidget, but for consistency of the API, I've also made this issue to concern QTableWidget - i.e. I am also suggesting a checkStateChanged signal for its and/or its items as well.

      I am of the opinion that one would find it most convenient to use in Qt Creator, if it were on QListWidget and QTableWidget; as opposed to their items - if it were an either/or proposition.

      I would say this sounds like a pretty straight-forward enhancement, except that it is for at least two classes, and Designer/Creator and the docs would have to be updated, too.  If, e.g., the itemChanged signal were to fire whenever a checkState changes, it would be simpler yet; but I would urge the docs nonetheless be updated to reflect this.

       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            codelurker Code Lurker
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes