I have a main window with a grid layout and has 8 buttons in 2 lines.
--------------------- | | | 1 2 3 4 | | | | | | 5 6 7 8 | | | ---------------------
I am trying to show a popup dialog next to the button that was clicked. So, I'm trying to get the coordinates of a button in a slot connected to a clicked() signal.
I tried
QPoint p = btn->pos();
and
QPoint p = btn->geometry().topLeft();
and both of them (0, 0) for some reason. How can I get the position of the button pressed in this slot?
thanks
source share