PDA

View Full Version : Moving whole rows between 3 different QTableWidgets after pressing buttons



And_re
11th May 2010, 15:46
Hi,
I want to ask you about the best way to implement moving whole rows between 3 different QTableWidgets after pressing buttons or when I get such a datagram from server.
This is how it looks like now:
4616
I have QMap<int, Player *> to store id and pointers of Player class where there are fields like: QString nick, quint8 team_id,...
When I press one of these join buttons I need to change team_id field of player who clicked it to 0 (Spectators), 1 (Home Team) or 2 (Away Team) and move the whole row with his id to proper QTableWidget. The same with information about other players changing their teams.

What do you think will be the best solution for this problem?

ChrisW67
12th May 2010, 01:46
Have you considered:

Using a single data model to hold your player info (QStandardItemModel or custom QAbstractTableModel)
Using a dynamic QSortFilterProxyModel to filter for each class of player
Replacing your QTableWidgets with QTableViews attached to the three proxy models

Changing the underlying data model should then automatically update your view tables.

And_re
12th May 2010, 15:27
I was thinking about creating some Model but have never tried it. I would also like to use it for many items on the scene. Automatic update of all views is what I'm looking for.