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. How to reload GridView

How to reload GridView

Scheduled Pinned Locked Moved QML and Qt Quick
5 Posts 4 Posters 5.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.
  • F Offline
    F Offline
    fas.ysk
    wrote on last edited by
    #1

    Hello,
    What's the right way to reload data in GridView ?

    for example:

    @function getSomeData(indx)
    {
    var str = pCore.getSomeData(indx);
    return str;
    }

    GridView {
    id: gridView
    model: 20
    delegate: Item {
    Text {
    text: getSomeData(index);
    }
    }
    }@

    pCore.getSomeData is method in C++ code like that: Q_INVOKABLE QString getSomeData(int nIndex);

    It works perfect but sometimes I need refresh data in items.
    How I can do it ?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      aabc
      wrote on last edited by
      #2

      Does the first text using getSomeData(index) is OK ?

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bibek
        wrote on last edited by
        #3

        Delegate shud be just a dummy item for displaying..
        You should get the data via a listModel. And on need of refresh, set listModel = 0 and again set listModel to desired array/model.

        1 Reply Last reply
        0
        • T Offline
          T Offline
          task_struct
          wrote on last edited by
          #4

          Hi,

          Why don't you present your data as QStringList? QStringList can be used as model - http://doc.qt.nokia.com/4.7-snapshot/qdeclarativemodels.html#qstringlist-based-model

          You can do something like this: In your C++ object define a property of type QStringList ( I think this is possible ). When you change some data in C++, emit signal that data has changed. This will automaticaly reload your model.

          "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

          • Linu...
          1 Reply Last reply
          0
          • A Offline
            A Offline
            aabc
            wrote on last edited by
            #5

            I also think this is the preferred way

            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