When you connect several signals to the same slot and you need to know in the slot which signal was emitted, you can use QSignalMapper. Basically it allows you to add an argument to the slot, of type int, QString, QWidget* or QObject*) to help you identify the emitter.
In your case I can suggest two options:
- embed the information in each button like SixDegrees suggested (e.g. by deriving QPushButton and declaring and initializing appropriate fields) and map each button to a pointer to itself (QWidget*) in the QSignalMapper; that way you get back the pointer in the slot and can read the information from the object.
- do not bother deriving QPushButton and map each button to an integer identifying it; for example, if i, j are the coordinates of a button (i in 0..5 and j in 0..6), map the button to the integer i * 7 + j; you can then use / and % to recover i and j from the integer in the slot.
Bookmarks