PDA

View Full Version : Best (and easiest) approach, QCombobox and QTableView...



scott_hollen
29th March 2011, 02:48
Soliciting thoughts from the pros out there...

I'm working on a "nice to have" for an app and wondering what everyone's thoughts are to the best approach to what I'm trying to do...To keep it simple and not bore everyone with my father-in-law's business, consider the following example...

A QSqlTableModel/QTableView of a DB table containing a First Name, Last Name, Sport, and Year Played.

The model/view is not editable unless the user clicks an Add row button...

Right now the user is entering these 4 fields by simply typing in the data -- per my father-in-law's request -- but being an Oracle programmer in real life, I'd prefer to have combobox's defined and displayed for the Sport and Year Played columns...These are separate validation/lookup tables in my DB and I can easily populate the comboboxes from them but I'm wondering what ya'll think is the easiest solution to including them in my model/view?

Should I follow this approach? http://www.qtcentre.org/threads/40044-Disable-row-rows-in-QTableView

Or can I use setindexwidget() to accomplish this?

thanks!


scott

wysota
29th March 2011, 09:57
QSqlRelationalDelegate

scott_hollen
29th March 2011, 14:07
Well, I feel stupid now...I'm using a delegate elsewhere but not in the same way...Didn't realize it automagically provided the combobox like this...

Thanks!


scott