Results 1 to 2 of 2

Thread: How to add new lines in a table view

  1. #1
    Join Date
    Jan 2006
    Location
    Stuttgart
    Posts
    10
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default How to add new lines in a table view

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to add new lines in a table view

    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.

Similar Threads

  1. displaying any table on a qdatatable
    By Philip_Anselmo in forum Newbie
    Replies: 4
    Last Post: 9th May 2006, 22:12
  2. creating table plugin
    By mgurbuz in forum Qt Programming
    Replies: 3
    Last Post: 28th April 2006, 13:50
  3. Adding row in a Table after selected row
    By ankurjain in forum Qt Programming
    Replies: 3
    Last Post: 20th April 2006, 18:06
  4. Replies: 6
    Last Post: 20th April 2006, 10:23
  5. Table model / view editing issue
    By Caius Aérobus in forum Qt Programming
    Replies: 9
    Last Post: 7th April 2006, 11:03

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.