/root/network/tcpserver.cpp:13: error: no matching function for call to 'TcpServer::connect(QTcpServer*&, void (QTcpServer::*)(), TcpServer* const, void (TcpServer::*)())'
时间: 2024-04-28 11:22:18 浏览: 92
这个错误提示是因为 connect 函数的第四个参数类型不正确,应该是指向 TcpServer 类中的成员函数指针。
请检查一下你传递给 connect 函数的第四个参数,确保它是指向 TcpServer 类中已经定义的成员函数的指针,并且函数指针的类型与参数列表和返回值类型完全匹配。如果你的代码中存在拼写错误或者函数参数不匹配等问题,也可能导致这个错误。
如果你无法解决这个问题,请提供更多的代码和上下文信息,以便更好地帮助你解决问题。
相关问题
connect(tcpsever,&QTcpServer::newConnection,this,&TcpServer::newconnet);报错/root/network/tcpserver.cpp:13: error: no matching function for call to 'TcpServer::connect(QTcpServer*&, void (QTcpServer::)(), TcpServer const, void (TcpServer::*)())'
这个错误提示是因为 connect 函数的第三个参数传递的是一个 const 对象,导致无法匹配正确的成员函数指针。
请将 connect 函数的第三个参数修改为指向非 const 的 TcpServer 对象指针,例如:
```
connect(tcpsever, &QTcpServer::newConnection, this, &TcpServer::newconnet);
```
注意,这里的第三个参数应该是指向非 const 的 TcpServer 对象指针 `this`,不能加上 const 限定符。
/home/lenovo/USB3/widget.cpp:19: error: no matching member function for call to 'setViewfinder'
这个错误信息表明在`/home/lenovo/USB3/widget.cpp`文件的第19行,编译器尝试调用`setViewfinder`函数,但没有找到匹配的成员函数。可能有以下几个原因导致这个错误:
1. **函数名拼写错误**:确保`setViewfinder`的拼写在所有地方都是一致的。
2. **函数参数不匹配**:检查调用`setViewfinder`时的参数是否与函数定义中的参数类型和数量一致。
3. **类中没有定义该函数**:确保`setViewfinder`函数在当前类的定义中存在。
4. **访问权限问题**:如果`setViewfinder`函数是私有的,而你在类的外部尝试调用它,会导致编译错误。
你可以按照以下步骤进行排查:
1. 检查`widget.cpp`文件中第19行的代码,确保函数名拼写正确。
2. 确认`setViewfinder`函数的定义,确保参数类型和数量与调用时一致。
3. 确认`setViewfinder`函数在当前类的定义中存在,并且访问权限正确。
示例代码:
```cpp
// widget.h
class Widget {
public:
void setViewfinder(int value);
};
// widget.cpp
#include "widget.h"
void Widget::setViewfinder(int value) {
// 函数实现
}
void Widget::someFunction() {
setViewfinder(10); // 第19行
}
```
如果以上步骤都没有发现问题,请提供更多相关代码,以便进一步排查。
阅读全文
相关推荐
![7z](https://img-home.csdnimg.cn/images/20241231044736.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)