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. ListModel and onChanged signals

ListModel and onChanged signals

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 3 Posters 3.6k Views
  • 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.
  • M Offline
    M Offline
    MrBlueSky125
    wrote on last edited by
    #1

    Has the ListModel element a special behavior on properties? I have this in a separate QML-File (OauthJsonListModel.qml):

    @ListModel {
    id: oauthJsonListModel

    property string source
    property string query: "payload"
    property bool oauthEnabled: token != "" && secret != ""
    property string token
    property string secret
    property string status: ""
    property string json
    
    signal oauthFailed
    signal requestError
    
    onSourceChanged: console.log("Bluub");
    

    }@

    But i get always this error:
    @ListModel: undefined property 'onSourceChanged'
    onSourceChanged: console.log("Bluub"); @

    When I remove the onSourceChanged handler, all works fine.
    It's strange. Did I miss something?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      chriadam
      wrote on last edited by
      #2

      ListModel and ListElement are special. They are parsed with a custom parser, and certain things which are supported for other object types are not supported for those types. It may be that automatic property-notifier and signal-handler generation, is one of those things. I'll confirm and reply to this thread when I find out for sure.

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        z.emb
        wrote on last edited by
        #3

        Thanks for the update so far. I assumed that there is something 'special' about ListModel.

        Is there any other basic QML type I can use for a model (which means I can assign it directly to a view)? I created a XML model equivalent, but for json files and included OAuth authentification and want to use it like the xml model.

        Of course, I could write a C++ class and do there all the fancy stuff, but I wanted to do this in pure qml/js, because it is .. JSON :-)

        Thanks again.

        Edit: (oops, logged in with the wrong account)

        1 Reply Last reply
        0
        • C Offline
          C Offline
          chriadam
          wrote on last edited by
          #4

          Just confirming that the warning you see is coming from the custom parser for ListModel elements. It seems that change signals aren't supported for that type.

          Regarding the model, you can still use a ListModel, but maybe use an intermediate Item element which has the various properties, and in the change signal handlers, set the appropriate source etc on the ListModel.

          Other things which can be used as a model for a view are listed in the docs at http://doc-snapshot.qt-project.org/5.0/qtquick-modelview.html (including object instances, etc).

          Cheers,
          Chris.

          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