Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Model View of QList<QObject*>of QAbstractListModel
Forum Updated to NodeBB v4.3 + New Features

Model View of QList<QObject*>of QAbstractListModel

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.2k Views 1 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.
  • G Offline
    G Offline
    gosuperninja
    wrote on last edited by
    #1

    I'm attempting to build a model inside a model and I'm not getting expected results. I'm putting a QObject with an invokable function called "get_models". This returns a QList<QObject*>. The list is populated with objects that derive from QAbstractListModel. The first repeater appears to work correctly. It calls the model_name invokable on my derived QAbstractListModel object. The unexpected results occur when I try to create a Repeater from the derived QAbstractListModel. It doesn't appear to recognize it as a model. When I print out the record numbers, it only states 1 for each model I pass in. When I provide the derived QAbstractListModel directly from the provider, rather than as a list, it returns the correct number of records.

    I'm guessing that when it's being handled by the inner repeater it's getting treated as "An Object Instance" instead of a QAbstractListModel object. Does this sound likely? Is there anything I can prove or disprove this? Also is there a work around or a better way of doing this?

    For example:

    @
    Column {
    height: 400
    width: 600
    Text { text: "Models" }

    Repeater {
    id: r1
    model: provider.get_models()
    delegate: Column {
    Text { text: "Model: " + modelData.model_name }
    Repeater {
    id: r2
    model: modelData
    Text { text: "Record Count " + r2.count }
    }
    }
    }
    }
    @

    [EDIT: code formatting, please wrap in @-tags, Volker]

    1 Reply Last reply
    0
    • G Offline
      G Offline
      gosuperninja
      wrote on last edited by
      #2

      This is post is not valid. I was passing in a QSharedPointer< QAbstractListModel > instead of just a QAbstractListModel*.

      This begs another question. After searching I didn't see any direct support in QML to handle QSharedPointer wrapped QObjects. Is this correct or did I miss something. If there isn't direct support. Any ideas?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        minimoog77
        wrote on last edited by
        #3

        No, there isn't QSharedPointer wrapped QObjects direct support in QML, as I know.

        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