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

QStandardItemModel::appendRow does not update correcty QStandardItem::columnCount

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P3: Somewhat important
    • None
    • 4.8.7, 5.11.1
    • Core: Item Models
    • None
    • Arch Linux current.
      Qt4 4.8.7.24
      Qt5 5.11.1.1
      PyQt4 4.12.1.1
      PyQt5 5.10.1.6
      PySide2 5.11.0.3
    • Linux/X11

    Description

      I create a multicolumn QStandardItemModel with plain QStandardItems

      if I add the columns via the appendRow method, the QStandardItem::columnCount() stays at 0 no matter how many columns I add to the row. But I can navigate via index.siblings() thru the row

       

      If I try to use the QStandardItem::appendColumn() or QStandardItem::insertColumn() things get even worse. Navigation via index.siblings() DOES NOT GIVE any columns but the row header (column 0).

      Using appendColumn(), the columnCount() is "one off" -only counts those appended via the method, and 0 with insertColumn.

      Worse still, if the model is a tree, usually the tree as such is corrupted using (append|insert)Column

      For completeness:

      QStandardItem::insertColumns() -beside its funny parametering (only starting pos and nr. of columns, no data), does update the count, but does not create any column items.
      QStandardItemModel::setItem() behaves correctly (updates the counter and makes the item) but can not be used in hierarchical models)

       

      Problem reproduces both in Qt4 and Qt5 at least this last year

      Problem can be bypassed not using columnCount() at all and adding columns via parent().setChild(), but ...

      I'm not a C++ man, so samples are written in Python. Problem reproduces in PyQt4, PyQt5 and PySide2, therefore I suspect is a pure Qt issue.
      Samples test_bug0.py  is a sample with appendRow
                     test_bug0_1.py a sample with appendColumn
                     test_bug0_2.py a sample with insertColumn

      I have samples for the behaviour with trees available if necesary

      Note: text updated 13/7 to better reflect which methods of which objects i'm refering, and adding aditional info for completeness

      Attachments

        1. bug69387_1.py
          3 kB
        2. test_bug0_1.py
          2 kB
        3. test_bug0_2.py
          2 kB
        4. test_bug0.py
          1 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            dfaure_kdab David Faure
            wllacer Werner Llácer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes