PDA

View Full Version : How to add new lines in a table view



klaus1111
17th August 2006, 00:25
Hi,
I have implemented a editable Model by subclassing QAbstractTableModel. It works with the data I added during initalising. I can move with "tab" from one field to the next and I can edit the content. Fine.
Now I want to have new rows - meaning, when I'm at the last colum of the last filled row and I press tab, I would like to have a new empty row where the user can add data.
Do I have to implement this by myself? (and how?) Or is there something allready provided to do this?

Thanks for any hints, Klaus
P.S.: I have allready an insertRow() function - but obviously it is not called

wysota
17th August 2006, 11:45
Hi Klaus, nice to hear from you again :)

The thing I would do is to reimplement event() for the widget and upon receiving a tab key press, check the current index of the view. If it is the last available (meaning row()==rowCount()-1 && column()==columnCount()-1), simply call insertRow (or whatever custom method you implement for adding rows) to make a new row. Just remember not to discard the event so that the tab key still moves you to the next entry.