0

I have a QTableWidget in my application and I have connected the cellClicked(int,int) signal to a slot. But this code in the slot doesn't get called at all when a cell is clicked. Please let me know how this can be resolved. This is my code:

connect(ui.tableWidget, SIGNAL(cellClicked(x,y)), this, SLOT(myCellClicked(x,y)));

Thanks, Rakesh.

ymoreau
  • 3,402
  • 1
  • 22
  • 60
Rakesh K
  • 8,237
  • 18
  • 51
  • 64

1 Answers1

1

The SIGNAL and SLOT macros only handle type names, not variable names, so it should be:

connect(ui.tableWidget, SIGNAL(cellClicked(int,int)), this, SLOT(myCellClicked(int,int)));
alexisdm
  • 29,448
  • 6
  • 64
  • 99
  • If I have a button in that cell, it looks like this signal is not being raised. How do I make sure this signal is also raised? – Rakesh K Jul 06 '12 at 13:32
  • @RakeshK I don't think that signal will be emitted if you have a real button in the cell. It would be better to paint a fake button with a delegate (see [that answer](http://stackoverflow.com/a/2767178/894321) ). – alexisdm Jul 06 '12 at 17:14