|
1Qter豆
请问各位 我是原来做MCU开发的 基本没有C++经验 现在学习QT开发 使用的环境是Windows+QT5.11 打算给单片机做个云端自动升级服务 ,现在程序遇到了技术问题 希望大家帮忙解决 谢谢了
void MyWidget::processNewConnection()
{
/* 每进来一次 创建一个这样的对象 然后在断开连接的时候 记得销毁都可以了 但是假如程序异常退出呢 这个空间十分释放?*/
/* 这个其实多线程并发处理了 只是不是线程 而是类的实例对象 */
mypCurTcpSocket = myTcpServer.nextPendingConnection();
ptcpClient.append(mypCurTcpSocket);
/* 绑定信号和槽函数 */
connect(mypCurTcpSocket, SIGNAL(disconnected()), this, SLOT(disconnectedFromHost()));
connect(mypCurTcpSocket, SIGNAL(readyRead()), this, SLOT(ReadData()));
ui->textEdit->append("客户端IP+PORT: ");
}
上面的 connect 函数使用 编译报错 。
.\ProUpgrade\mywidget.cpp: In member function 'void MyWidget::processNewConnection()':
..\ProUpgrade\mywidget.cpp:89:88: error: no matching function for call to 'MyWidget::connect(QTcpSocket*&, const char*, MyWidget*, const char*)'
connect(mypCurTcpSocket, SIGNAL(disconnected()), this, SLOT(disconnectedFromHost()));
^
In file included from D:\Qt\Qt5.11.2\5.11.2\mingw53_32\include\QtWidgets/qwidget.h:45:0,
from D:\Qt\Qt5.11.2\5.11.2\mingw53_32\include\QtWidgets/QWidget:1,
from ..\ProUpgrade\mywidget.h:5,
from ..\ProUpgrade\mywidget.cpp:1:
D:\Qt\Qt5.11.2\5.11.2\mingw53_32\include/QtCore/qobject.h:208:36: note: candidate: static QMetaObject::Connection QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType)
static QMetaObject::Connection connect(const QObject *sender, const char *signal,
^
D:\Qt\Qt5.11.2\5.11.2\mingw53_32\include/QtCore/qobject.h:208:36: note: no known conversion for argument 1 from 'QTcpSocket*' to 'const QObject*'
D:\Qt\Qt5.11.2\5.11.2\mingw53_32\include/QtCore/qobject.h:211:36: note: candidate: static QMetaObject::Connection QObject::connect(const QObject*, const QMetaMethod&, const QObject*, const QMetaMethod&, Qt::ConnectionType)
static QMetaObject::Connection connect(const QObject *sender, const QMetaMethod &signal, |
|