How to reload GridView

  • 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 ?

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

  • 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.

  • Hi,

    Why don't you present your data as QStringList? QStringList can be used as 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.

  • I also think this is the preferred way

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.