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 refresh the data show after the model filtered by DelegateModel?
Forum Updated to NodeBB v4.3 + New Features

How to refresh the data show after the model filtered by DelegateModel?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
delegatemodelqml c++filter
1 Posts 1 Posters 353 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.
  • K Offline
    K Offline
    kongkong
    wrote on 4 Aug 2022, 01:18 last edited by
    #1

    I have defined a model by QAbstractListModel, and show the data filtered by DelegateModel. The data in the items of the model is dynamic, and refreshes by a certain frequency. When the includeByDefault property of DelegateModelGroup is true, the data on the screen is changing correctly as the data of model is refreshing, but when includeByDefault is false and begin to filter the model, the data on the screen is still on the initial state.
    Below is the code:

       DelegateModel{
            id: displayedModel
            model: profModel
    
            delegate: dataDelegate
            groups: [
                DelegateModelGroup{
                    includeByDefault: false//true
                    name: "byAreaTitle"
                }
            ]
            filterOnGroup: "byAreaTitle"
    
            Component.onCompleted: {
                rowCount = profModel.rowCount();
                items.remove(0, rowCount);
                for(var i=0; i<rowCount; i++)
                {
                    entry1 = profModel.getEntry(profModel.index(i, 0));
                    if(entry1.titleBelong === columnTitle)
                        items.insert(entry1,"byAreaTitle");
            }
        }
        
        }
    
        GridView {
            id: gridArea
            width: parent.width - 2
            anchors.top: cTitle.bottom
            anchors.bottom: parent.bottom
            anchors.topMargin: 10
            anchors.horizontalCenter: parent.horizontalCenter
            cellHeight: 18
            cellWidth: width / 10
            model: displayedModel//profModel
    
        }
    
        Component{
            id: dataDelegate
            WLValueShow{
                vname: sndDisplayName
                value: displayStr
                unitName: unit
            }
        }
    

    What is the situation, and how to solve this problem?
    thanks.

    1 Reply Last reply
    0

    1/1

    4 Aug 2022, 01:18

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved