Hello!

I write an app in Java using Jambi. In application a have a table with some data (list of music files), the problem is that when I am adding data to the table not all data is added if I am using following code:

Qt Code:
  1. Iterator<MediaFileBean> it = list.iterator();
  2. QAbstractItemModel model = instance.model();
  3. model.removeRows(0, model.rowCount());
  4.  
  5.  
  6. while (it.hasNext()) {
  7. int row = model.rowCount();
  8. model.insertRow(row);
  9. MediaFileBean mf = it.next();
  10. model.setData(row, ALobsterPlaylist.TITLE_INDEX, mf.getTitle());
  11. model.setData(row, ALobsterPlaylist.HIDDEN_INDEX, mf.getFile());
  12. }
To copy to clipboard, switch view to plain text mode 

also I tried to add with following code:

Qt Code:
  1. Iterator<MediaFileBean> it = list.iterator();
  2.  
  3. QAbstractItemModel model = instance.model();
  4. model.removeRows(0, model.rowCount());
  5.  
  6.  
  7. while (it.hasNext()) {
  8. int row = instance.rowCount();
  9. instance.insertRow(row);
  10. MediaFileBean mf = it.next();
  11. instance.setItem(row, ALobsterPlaylist.TITLE_INDEX, new QTableWidgetItem(mf.getTitle()));
  12. instance.setItem(row, ALobsterPlaylist.HIDDEN_INDEX, new QTableWidgetItem(mf.getFile()));
  13. }
To copy to clipboard, switch view to plain text mode 

"instance" is instance of QTableWidget

Here is link to screenshot: http://www.qtforum.org/index.php?pag...0168a5088fd95c, the las column must be filled completely.

Also I tried this code:

Qt Code:
  1. Iterator<MediaFileBean> it = list.iterator();
  2. int row = 0;
  3. QAbstractItemModel model = instance.model();
  4. model.removeRows(0, model.columnCount());
  5. model.insertRows(0, list.size());
  6.  
  7. while (it.hasNext()) {
  8. MediaFileBean mf = it.next();
  9. model.setData(row, ALobsterPlaylist.TITLE_INDEX, mf.getTitle());
  10. row++;
  11. }
  12.  
  13. it = list.iterator();
  14. row = 0;
  15. while (it.hasNext()) {
  16. MediaFileBean mf = it.next();
  17. model.setData(row, ALobsterPlaylist.ARTIST_INDEX, mf.getAuthor());
  18. row++;
  19. }
  20.  
  21. it = list.iterator();
  22. row = 0;
  23. while (it.hasNext()) {
  24. MediaFileBean mf = it.next();
  25. model.setData(row, ALobsterPlaylist.ALBUM_INDEX, mf.getAlbum());
  26. row++;
  27. }
  28.  
  29. it = list.iterator();
  30. row = 0;
  31. while (it.hasNext()) {
  32. MediaFileBean mf = it.next();
  33. long m = TimeUnit.MINUTES.convert(mf.getDuration(), TimeUnit.MICROSECONDS);
  34. long s = TimeUnit.SECONDS.convert(mf.getDuration(), TimeUnit.MICROSECONDS);
  35. model.setData(row, ALobsterPlaylist.DURATION_INDEX, m + ":" + (s % 60));
  36. row++;
  37. }
  38.  
  39. it = list.iterator();
  40. row = 0;
  41. while (it.hasNext()) {
  42. MediaFileBean mf = it.next();
  43.  
  44. System.out.println(mf.getTitle() + " : " + mf.getFile());
  45.  
  46. model.setData(row, ALobsterPlaylist.HIDDEN_INDEX, mf.getFile());
  47. row++;
  48. }
To copy to clipboard, switch view to plain text mode 

It's filling all the rows and columns, but the data in columns is not coresponding to rows.
Ex:
I must have rows

Qt Code:
  1. A1 A2 A3
  2. B1 B2 B3
  3. C1 C2 C4
To copy to clipboard, switch view to plain text mode 


But in result I have
Qt Code:
  1. A1 C2 C3
  2. B1 A2 B3
  3. C1 B2 A3
To copy to clipboard, switch view to plain text mode 
smth like this

So how to solve the problem, some sugestions

THX