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

QDeclarativeVisualDataModel::count() weirdness

XMLWordPrintable

    • 6cf397f7ac35a058096528a7ad8bfaf623b30747, 07b9a2f2f74a42c83ac95f144392437001a455bb

      We had some weird thing going on while porting Listview over to the new QScroller:
      Let's say you have QDeclarativeVisualDataModel vdm with 9 items and no delegate.

      vdm->count() is 9 and that's ok (or not?)

      now as soon as you set a delegate via QDeclarativeVisualDataModel::setDelegate(), you will get a itemsInserted() signal telling you that 9 items were inserted.
      After that

      vdm->count() is still 9 and that's weird now. We had 9, we got an insertion notification for another 9 and we still only have 9?

      My guess is that something like this patch would make it a lot saner (0 items via count() as long as we don't have a delegate)

      diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
      index e569dd2..0199a6a 100644
      --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
      +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp
      @@ -937,6 +937,8 @@ void QDeclarativeVisualDataModel::setPart(const QString &part)
       int QDeclarativeVisualDataModel::count() const
       {
           Q_D(const QDeclarativeVisualDataModel);
      +    if (!d->m_delegate)
      +        return 0;
           return d->modelCount();
       }
      

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

            martjone Martin Jones (closed Nokia identity) (Inactive)
            griebl Robert Griebl (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes