QML Update Gridview from QML or C++ without emit dataChanged
Is Deckmodel
the same thing as Playerfield
in your code? When changing your model, you need to call begin/endResetModel(). That will automatically emit the appropriate signals so your QML should update correclty.
void Deckmodel::sortDeck()
{
beginResetModel();
for(uint a = 0; a < cards.size(); a++)
{
for(uint b = a+1; b < cards.size(); b++)
{
if(cards[a].type > cards[b].type)
{
Card temp = cards[a];
cards[a] = cards[b];
cards[b] = temp;
}
}
}
endResetModel();
}