-1

I have a QTableWidget, if a cell is clicked, I want to emit a signal to the MainWindow.

My Header File:

QTableWidget *myQtableWidget= new QTableWidget;
...
private slots:
    void on_myTableWidgetWindow_cellClicked(int row, int column);

mainWindow.cpp (in the constructor of the mainWindow):

connect(this->myQtableWidget, SIGNAL(cellClicked(int row, int column)),
        this, SLOT(on_myTableWidgetWindow_cellClicked(int row, int column)));

mainWindow.cpp (somewhere):

void mainWindow::on_myTableWidgetWindow_cellClicked(int row, int column)
{
//do something
}

The console output is:

QMetaObject::connectSlotsByName: No matching signal for on_myTableWidgetWindow_cellClicked(int,int)
QObject::connect: No such signal QTableWidget::cellClicked(int row, int column) in ..\myProg\windowMain.cpp:71
QObject::connect:  (receiver name: 'mainWindow')

Why is the console telling me : "No such signal QTableWidget::cellClicked"? In the QT-Docs, this signal is listed: http://doc.qt.io/qt-5/qtablewidget.html#cellClicked

I can't see my mistake, can anyone help? best,

sandwood
  • 2,038
  • 20
  • 38
Hoehli
  • 154
  • 10
  • 3
    It should be `connect(this->myQtableWidget, SIGNAL(cellClicked(int, int)), this, SLOT(on_myTableWidgetWindow_cellClicked(int, int)));` instead. No need to include the functions parameters names. – vahancho Sep 24 '18 at 08:52
  • 3
    Better still, use the new [`Qt5` signal/slot syntax](https://wiki.qt.io/New_Signal_Slot_Syntax) -- `connect(this->myQtableWidget, &QTableWidget::cellClicked, this, &MainWindow::on_myTableWidgetWindow_cellClicked)`. – G.M. Sep 24 '18 at 09:04
  • ... and [QTableView selectionChanged](https://stackoverflow.com/questions/2376052/qtableview-selectionchanged)... – scopchanov Sep 24 '18 at 13:39

1 Answers1

1

Apparently you can simply get rid "row" and "column". I mean:

connect(this->myQtableWidget, SIGNAL(cellClicked(int, int)), 
        this, SLOT(on_myTableWidgetWindow_cellClicked(int, int)));
sassi67
  • 77
  • 1
  • 4