1

I am adding 2 buttons in each cell of my Qtablewidget and I want to perform a specific action for each clicked button. The problem is that I am only able to detect the click on the entire cell but not which clicked button. I am using pyqt4 and Python 3.5

Could you please help me to solve this problem? Thanks

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Ikram Romdhani
  • 33
  • 1
  • 3
  • 6

1 Answers1

0

I guess you are already watching the QTableWidget::cellClicked(int row, int column)-signal with some slot, or? You could try to acquire the sender, which of both buttons it was, by something similar to this:

#include <QtCore/QMetaObject>
#include <QtCore/QMetaMethod>

{
    QMetaMethod const metaMethod = sender()->metaObject()->method(senderSignalIndex());
    qDebug() << "invoking caller: name and signature:" << metaMethod.name() << "|" << metaMethod.methodSignature();
}

(please adapt yourself to PyQt).


Or: you add connections for each of the buttons for each cell at the creation.

Skandix
  • 1,916
  • 6
  • 27
  • 36
Marcel Petrick
  • 454
  • 3
  • 15