PDA

View Full Version : multiple calls to QTableWidget::cellDoubleClicked(int,int) slot



jcg
31st May 2014, 12:10
Hello everybody,

This is my fist post on this forum. I am a rather experimented programmer on Visual C++ and have been moving to Qt since a few months (with the idea of never come back to VC++). I use Qt 5.2.0 with the minGW compiler on Windows 7 64bits.

I have a MDI application, each MDI child window contains a QSplitter, one of the panes of the Splitter contains a QTabWidget which in turn contains a QTableWidget. I want deal with a double click on a cell of the QTableWidget* tableWidget on the splitter window (because I want to act on another pane of the splitter), so I wrote a public slot in the splitter window 'on_cellDoubleClicked(int row,int col)' and connected it:

connect(tableWidget,SIGNAL(cellDoubleClicked(int,i nt)),this,SLOT(on_cellDoubleClicked(int,int)));

The connection works fine, the problem is that when I double-click ONCE on a tableWidget cell, the slot on_cellDoubleClicked(int,int)) is called MANY TIMES in succession, typically eigth times.

Does someone knows what is the problem ? Thanks in advance.

Jean-Claude

anda_skoa
31st May 2014, 13:38
This is strange.

Could you have multiple connections to the same slot, e.g. the same connect having been executed multiple times or the signal being connected to multiple receiver instances?

Cheers,
_

jcg
31st May 2014, 16:15
Your are perfectly right. Instead of calling connect() in the constructor, I called it on the function that displays data on the QTableWidget. I moved the connect() to the constructor and the problem disapeared!

Thank you very much!