Hi Gunnar, thanks for your reply. I got it working with beginInsertRows() and endInsertRows() but i think, that i don't implemented it correctly :-) Is there any example available?
Here is what i have done. Please correct me, if my way of thinking is wrong: I have an Array, ArrayList or whatever i want to show in the table. For example a list of File-Objects. I want to list these files in the table (filename, file size etc.). So my TableModel has to know the ArrayList. I transfer this ArrayList to the TableModel via a parameter in the contructor. Is this the best way to give the TableModel access to the ArrayList? Now my program manipulates the ArrayList in the background. For example i add or delete files. Should i now call the beginInsertRows() and endInsertRows()-functions manually to get the GUI to be updated? Or is there a possibility, that the TableModel recognizes itself, that the ArrayList has changed. Actually i fire an event when the ArrayList changes and call an update-Function which call the beginInsertRows() and endInsertRows() functions. How do i use the TableModel correctly? I don't want to write Quirks-Code :D A little example would be nice and helpful :) Best Regards, Manuel Gunnar Sletta schrieb: > Manuel wrote: >> Hello, >> >> i have problems using QAbstractTableModel. >> >> First, here is my code: http://pastebin.com/m2193e552 >> >> My TableModel is very simple. It should show some data from an >> ArrayList of my program. >> The ArrayList is part of my program and is only referenced in the >> TableModel (via Constructor). >> >> So far so good. >> I manipulate the ArrayList outside the TableModel, eg in a >> Main-Method. For example i add 3 objects to the ArrayList. > > Do you surround your array manipulation with beginInsertRows() and > endInsertRows()? Without this the results are undefined. > >> But the crazy thing is, that the data() function will never be called >> and no rows were shown. >> Even if i call the dataChanged.emit()-method nothing happens. The >> Table stays empty. > > the dataChanged signal only tells the model that the content of the > given cell changed, not that the structure of the cells changed. You > need to do use the begin/end functions to do that. > > - > Best regards, > Gunnar > _______________________________________________ Qt-jambi-interest mailing list [email protected] http://lists.trolltech.com/mailman/listinfo/qt-jambi-interest
