Hi, I have a QTableView with a QSortFilterProxyModel as it's model. Source model for the proxy is a custom model subclassing QAbstractTableModel. I update the source model every minute. I made a function for that thats get called every minute:
	
	- void CustomModel::update() 
- { 
-     for(int i = 0; i < alarms.size(); i++) 
-         alarms[i]->addMinute(); 
-   
-     timer -- >start ((60 - QTime::currentTime()- . second()) *1000)- ; 
-   
-     emit dataChanged(index(0, 0), index(alarms.size(), 3)); 
- } 
        void CustomModel::update()
{
    for(int i = 0; i < alarms.size(); i++)
        alarms[i]->addMinute();
    timer->start((60 - QTime::currentTime().second()) *1000);
    emit dataChanged(index(0, 0), index(alarms.size(), 3));
}
To copy to clipboard, switch view to plain text mode 
  
The problem is that the proxy model doesn't update it's values, except if i repaint the window (by minimizing and maximizing the window), or click a table header. Also i want it sorted, and does that a couple of times, but later it stops. Here is the code i use on my main window:
	
	- proxyModel->setSourceModel(&CustomModelInstance); 
-     proxyModel->setDynamicSortFilter(true); 
-     proxyModel->sort(2, Qt::DescendingOrder); 
        proxyModel->setSourceModel(&CustomModelInstance);
    proxyModel->setDynamicSortFilter(true);
    proxyModel->sort(2, Qt::DescendingOrder);
To copy to clipboard, switch view to plain text mode 
  
I thought that by calling dataChanged() when updating values on the source model every proxy model should also update itself. What im doing wrong?
				
			
Bookmarks