是服务器的端口没有打开。
1、首先pro文件配置:Qt网络功能需要在pro文件增加网络库。
2、QTcpServer服务端建立的方法代码,如下图所示。
3、QTcpServer当有新客户端连接时,会发出QTcpServer::newConnection的信号方法代码。
4、客户端为主动连接方不需要监听,直接建立QTcpSocket代码。
5、最后通过connectToHost连接指定ip和端口,将socket的连接成功的信号与对应槽连接,当连接成功可以将自定义的标记位置为true。
注意事项:
int main()
{
Py_Initialize(); // 初始化// 将Python工作路径切换到待调用模块所在目录,一定要保证路径名的正确性string chdir_cmd = string("sys.path.append(\'/xxxxxxx/')");
// 加载模块PyObject* moduleName = PyString_FromString("xx"); //模块名,不是文件名PyObject* pModule = PyImport_Import(moduleName);
// 加载函数PyObject* pv = PyObject_GetAttrString(pModule, "xxx");// 调用函数PyObject* pRet = PyObject_CallObject(pv, xxx);