@squidge - I agree, model / view is much more appropriate for this (and for most other cases where there is a data collection behind a table, IMO).
@fatecasino: However, if you really want to use a QTableWidget instead of a QTableView and model:
1 - you need to create a connection from the QTableWidget's cellClicked() signal to a slot so you know -which- combobox is being edited.
2 - you need to connect each combobox's currentIndexChanged() signal to a slot so you can tell when the user has made a new selection.
3 - the combination of these first two signals will tell you (a) which combox box is in use and (b) what selection the user made.
4 - when the user clicks the Add button, you can do one of the following:
(a) Read each cell in the current row and retrieve either its text (if it is an ordinary QTableWidgetItem that-you- have created and put there) or retrieve the widget (using cellWidget()) and then use that pointer to read the selected text.
(b) Store the row information somewhere in your application external to the table, and update it in response to combobox currentIndexChanged () or table widget itemChanged() signals. Use this to populate the new row in the table.
But as squidge suggested, you're doing this the hard way. Read up on model / view (not just the class documentation, but read the tutorial stuff too).
Bookmarks