Results 1 to 3 of 3

Thread: Modified tableview

  1. #1
    Join Date
    Mar 2006
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Modified tableview

    I would like to have a tableview, getting data from a relational sql model. The tableview would display a few of the fields of the table, but when a row is selected, allow editing of all the fields in some kind of dialog type widget contained within an enlarged row of the table view.

    The delegate classes draw and edit cells, ie a certain row/column. You can paint or customize the cell, but not the whole row at a time. Or so I can determine.

    Obviously I'm going to have to subclass a bunch of things, but where would a person start? Which class initiates the drawing sequences, initiates the what eventually calls the delegate to generate an editor?

    I thought of modifying the model class to output a 1 column tableview, then painting the wide cell with the fields in the unselected rows. The selected row would be made larger, and a widget with editing widget children used. Does that make sense?

    Thanks
    Derek

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    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: Modified tableview

    You don't have to subclass anything. You just need to connect some signals of your choice to a custom slot which will create a QDialog based dialog and fill it with widgets to edit the fields. All field data can be taken from the model itself using the record() method.

  3. #3
    Join Date
    Mar 2006
    Posts
    7
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Modified tableview

    Reading the qtableview code, I think I can see a way forward.

    On a call for the table to paint, the method figures out columns and rows from the qheaderviews. It then iterates through the rows, and calls the delegate to draw each cell, passing info such as selected and other so the delegate can draw properly. It then draws the grid if required. The delegate gets the record and field data from the model.

    If I subclass the tableview paint method, if not selected proceed as normal, if selected, (or even better, if current) flag it as such, get the size hint from the delegate, and give it the row height and full width of the table. The delegate could then draw the widgets as required.

    I don't want to pop up another dialog. The table contains data that needs to be handled and passed onto somewhere else. The tableview would show only 3 columns, but to edit requires another 4 widgets plus some buttons to take some action. The selected row would show all the widgets, the non selected would look like normal tableview rows and columns.

    Derek

Similar Threads

  1. Drag an item from QTreeWidget and drop in TableView
    By steg90 in forum Qt Programming
    Replies: 8
    Last Post: 18th May 2007, 11:42
  2. tableview and layouts
    By zorro68 in forum Qt Programming
    Replies: 1
    Last Post: 10th February 2007, 17:21
  3. Retrieving modified date of file using QHttp
    By hardgeus in forum Qt Programming
    Replies: 9
    Last Post: 3rd December 2006, 23:20
  4. TreeView, TableView
    By rbrand in forum Qt Programming
    Replies: 1
    Last Post: 4th July 2006, 08:54
  5. How to link modified file
    By awalesminfo in forum Newbie
    Replies: 4
    Last Post: 22nd March 2006, 17:24

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.