[Qt-interest] QPushButton as delegate widget in a QTableView?

Robert Hairgrove evorgriahr at hispeed.ch
Fri Feb 18 17:48:26 CET 2011


My table view displays the metadata for a column of a database table in
each row. Columns of the table view are: Name, data type, length (if
applicable), unique and nullable.

The user can edit the properties directly in the table view using custom
delegates. For the data-type column, I have a combo box; for the length
column, a spin box; and for the last two columns, checkboxes.

What I would like to do is to add a new row (or edit an existing row)
and show one or two push buttons in the last column of the table view
with appropriate icons or "Save"/"Cancel" captions. It doesn't look like
using a custom delegate for this would work because the buttons need to
be visible all the time until the editing has been finished.

What would be the best approach for doing this? I could put the buttons
outside of the table view, but I think from a GUI design point of view
it would be better if they were displayed directly with the row being
edited. Could I just add these buttons as children of the table view's
client window, or scroll area, and get the geometry and position of the
cell at the end of the row in order to line them up with the data being
edited?

Thanks for any suggestions!




More information about the Qt-interest-old mailing list