Qt:未找到 QTableWidget::cellClicked signal/slot 的问题
Qt: problem with QTableWidget::cellClicked signal/slot not found
我有一个 QTableWidget,如果单击一个单元格,我想向 MainWindow 发出一个信号。
我的头文件:
QTableWidget *myQtableWidget= new QTableWidget;
...
private slots:
void on_myTableWidgetWindow_cellClicked(int row, int column);
mainWindow.cpp(在mainWindow的构造函数中):
connect(this->myQtableWidget, SIGNAL(cellClicked(int row, int column)),
this, SLOT(on_myTableWidgetWindow_cellClicked(int row, int column)));
mainWindow.cpp(某处):
void mainWindow::on_myTableWidgetWindow_cellClicked(int row, int column)
{
//do something
}
控制台输出为:
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')
为什么控制台告诉我:"No such signal QTableWidget::cellClicked"?
在 QT-Docs 中,列出了这个信号:http://doc.qt.io/qt-5/qtablewidget.html#cellClicked
我看不出我的错误,有人可以帮忙吗?
最好的,
显然您可以简单地删除 "row" 和 "column"。我的意思是:
connect(this->myQtableWidget, SIGNAL(cellClicked(int, int)),
this, SLOT(on_myTableWidgetWindow_cellClicked(int, int)));
我有一个 QTableWidget,如果单击一个单元格,我想向 MainWindow 发出一个信号。
我的头文件:
QTableWidget *myQtableWidget= new QTableWidget;
...
private slots:
void on_myTableWidgetWindow_cellClicked(int row, int column);
mainWindow.cpp(在mainWindow的构造函数中):
connect(this->myQtableWidget, SIGNAL(cellClicked(int row, int column)),
this, SLOT(on_myTableWidgetWindow_cellClicked(int row, int column)));
mainWindow.cpp(某处):
void mainWindow::on_myTableWidgetWindow_cellClicked(int row, int column)
{
//do something
}
控制台输出为:
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')
为什么控制台告诉我:"No such signal QTableWidget::cellClicked"? 在 QT-Docs 中,列出了这个信号:http://doc.qt.io/qt-5/qtablewidget.html#cellClicked
我看不出我的错误,有人可以帮忙吗? 最好的,
显然您可以简单地删除 "row" 和 "column"。我的意思是:
connect(this->myQtableWidget, SIGNAL(cellClicked(int, int)),
this, SLOT(on_myTableWidgetWindow_cellClicked(int, int)));