Let me restate a few things that I think that you said:
1. You know how to write a "slot"
2. You have an array of 20 buttons.
I assume that you already know how to connect your buttons to your slot that lets you know that a button was clicked. I assume that your real problem is that you have no idea what button was clicked. It looks like you are suggesting that you can use the mouse position to determine this. Off hand, I expect that the mouse location is not related at all, since I might hover the mouse over one button and then use the keyboard to cause a totally different button to be "clicked".
It turns out that QT has a calculator button that demonstrates how to solve this:
http://qt-project.org/doc/qt-4.8/widgets-calculator.html[
^]
This contains the following line of code in the slot
Button *clickedButton = qobject_cast<Button *>(sender());
The descriptive text states the following:
Quote:
First, we find out which button sent the signal using QObject::sender(). This function returns the sender as a QObject pointer. Since we know that the sender is a Button object, we can safely cast the QObject. We could have used a C-style cast or a C++ static_cast<>(), but as a defensive programming technique we use a qobject_cast(). The advantage is that if the object has the wrong type, a null pointer is returned. Crashes due to null pointers are much easier to diagnose than crashes due to unsafe casts. Once we have the button, we extract the operator using QToolButton::text().