You always assign to ui.tableWidget, so that holds the reference to the last table widget that got created.
Cheers,
_
You always assign to ui.tableWidget, so that holds the reference to the last table widget that got created.
Cheers,
_
I see. So each tableWidget as it is created is assigned to ui.tablewidget and overwrites the previous one. I need to save each one to a list as it is created, the only problem that I have with that is how do I get them out of the list?
A list is usually addressed via index.
The first item is at index 0, the second at index 1 and so on.
You can also store the references in an associative container, where the key is not a number but e.g. a string.
Cheers,
_
I understand that the list is addressed by index, but I don't see how the signal can know what the index is. When the signal is created in the loop and the tableWidget reference is saved to the list, is there some connection that happens so the signal knows what listWidget reference to use?
The signal does not know anything about an index, but the slot can get the sender of the signal that caused the slot to be called.
Alternatively you can create a "signal handler" class, i.e. a class derived from QObject to handle all signals for one single table view, and then create one instance of that class for each table view.
Cheers,
_
Yes, that would be the actual reference to the tableWidget, whether it is saved somewhere else or not doesn't matter.
See QObject::sender().
Cheers,
_
Bookmarks