Suppose I have some QPushButton
s displayed in a QListWidget
or QTableWidget
. The QPushButtons
connect to the same slot function that carries out the same action for their relative list item or table row.
I am not sure if I am thinking in the right direction:
Suppose that the list items or table rows are created in a for
loop, looping a list, for example. During the creation of the list item, or table row, along with the QPushButton
in it, I am supposed to store some sort of data, or id, into the QPushButton
, so that when the QPushButton
is clicked, its connected slot will know which QPushButton
is clicked and carry out some operation specifically to the QPushButton
's parent list item/table row. (assuming I am using the same one slot function for all the QPushButton
s)
So my question is: Given that the list items or table rows are created in a for
loop of a list, how do I store some sort of list-related value(s) into the QPushButton
and how do I retrieve the value(s) inside the slot function?
I suppose my question isn't really bound to QPushButton
s. The same question can go to QCheckBox
es, QLineEdit
s, or any QWidget
s in general as long as they can send out signals.