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. A very strange problem for List View and loader

A very strange problem for List View and loader

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

    Hi everyone,

    I encounted a very strange problem, which is decribed below:

    I have a loader, which loads different qml files. for example:

    two qml files:
    A.qml
    B.qml
    in B.qml, there is a ListView:
    @Rectangle{
    width:360
    height:640
    ListView{
    anchors.fill:parent
    model:MyModel{}
    Delegate: myDeletage
    }
    } @

    First, i load B.qml, then i load A.qml. Now, i changed MyModel.qml, and then reload B.qml. but the listview is the same as before. it is not changed according to new model.

    I dont know why it is, because loader is for creating objects dynamically. It destroys the previous object totally, isn't it?

    Thanks in advance

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbrasser
      wrote on last edited by
      #2

      This is likely due to the parsing of MyModel.qml being cached (the engine doesn't expect/handle .qml files changing on-the-fly). I can't think of any easy workarounds at the moment; you'll likely need to restructure the model handling somehow (using a C++ model; or keeping MyModel persistant and manipulating it from QML, rather than rewriting the file; or passing different models into B through e.g. a property alias).

      Regards,
      Michael

      1 Reply Last reply
      0
      • H Offline
        H Offline
        huluyige
        wrote on last edited by
        #3

        Thank you very much Michael,

        I understand, i will try to restructure the application.

        [quote author="mbrasser" date="1301008595"]This is likely due to the parsing of MyModel.qml being cached (the engine doesn't expect/handle .qml files changing on-the-fly). I can't think of any easy workarounds at the moment; you'll likely need to restructure the model handling somehow (using a C++ model; or keeping MyModel persistant and manipulating it from QML, rather than rewriting the file; or passing different models into B through e.g. a property alias).

        Regards,
        Michael[/quote]

        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