Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Refreshing model in Repeater



  • Hi! This is my first post! I was learning a bit of QT for first time this last week. I started trying to create some really simple KDE plasmoids based on others, and I'm struggling a bit with some topics.

    So I have a Repeater that gets a bunch of data related with events. So I want to filter the content of the model to get specific data based on the date

    so I have implemented a plasma model for filtering it

                              model: PlasmaCore.SortFilterModel {
    				id: test
    					filterCallback: function(index, date) { 
    						return date.toDateString() == selectedDate.toDateString()
    					}
    					sourceModel: root.agendaModel
    				}
    

    And this works. It filters to only show the data that has the same date as the selectedDate. So. I want this to be repainted, refreshed, retrigered or updated (not sure what kind of concept would be) when I change selectedDate.

    I creted a connection in my QML with the parent QML so whenever the selectedDate changes it fires the event function 'onDateSelected'

    Connections {
    		target: monthView
    		onDateSelected: {
    			// logger.debug('onDateSelected', selectedDate)
    			console.log("I think here I need to trigger an update")
    		}
    	}
    

    This works too, selectedDate variable gets updated but I can't figure out how I could refresh the model to trigger again the filterCallback function.

    I'm actually not sure if this is something more specific with PlasmaCore than QT itself. Sorry if this is the case.


Log in to reply