Qt5:error: no matching function for call to 'MainWindow::connect()
程序员文章站
2022-03-30 21:56:27
...
报错代码:
connect(ui->chartComboBox,&QComboBox::currentIndexChanged,this,&MainWindow::getChartIndex);
报错内容:
E:\Qt_Project\QtCharts\mainwindow.cpp:22: error: no matching function for call to 'MainWindow::connect(QComboBox*&, <unresolved overloaded function type>, MainWindow*, void (MainWindow::*)(int))'
connect(ui->chartComboBox,&QComboBox::currentIndexChanged,this,&MainWindow::getChartIndex);
报错原因:
在使用QComboBox类的信号函数时,因为函数currentIndexChanged重载,出现多个参数,导致Qt5编译器不知道要匹配那个函数,于是就出现了unresolved overloaded function type这种情况。
void currentIndexChanged(int index);
void currentIndexChanged(const QString &);
解决方法:
1、强制类型转换
connect(ui->chartComboBox,static_cast<void (QComboBox::*)(int index)>(&QComboBox::currentIndexChanged),this,&MainWindow::getChartIndex);
connect(ui->chartComboBox,static_cast<void (QComboBox::*)(const QString &)>(&QComboBox::currentIndexChanged),this,&MainWindow::getChartIndex);
2、改用Qt4版本的语法
上一篇: javaFx屏幕截图工具
下一篇: ubuntu16.04安装qt4.8.7
推荐阅读
-
php连接mysql出错:Fatal error: Call to undefined function mysql_connect(),该如何处理
-
php连接mysql出错:Fatal error: Call to undefined function mysql_connect(),该如何处理
-
Fatal error: Call to undefined function mysql_connect() in E:appserverapach...
-
php连接mysql出错:Fatal error: Call to undefined function mysql_connect(),该如何处理
-
Fatal error: Call to undefined function mysql_connect()解决方法
-
PHP连接MySQL报错:Fatal error: Call to undefined function mysql_connect()之解决方法
-
php中的Fatal error: Call to undefined function ssh2_connect()有关问题!
-
Fatal error: Call to undefined function mssql_connect()解决办法
-
PHP连接MySQL报错:Fatal error: Call to undefined function mysql_connect()之解决方法
-
Qt报错:error: no matching function for call to ‘MainWindow::connect(QAction*&, void (QAction::*)