【发布时间】:2012-03-01 14:48:55
【问题描述】:
我正在编写一些代码来建立 TCP 套接字,但在尝试设置我尝试收听的信号时遇到错误。
代码是:
connection = new QTcpSocket(this);
connect(connection,SLOT(connected()),this,SIGNAL(onConnection()));
connect(connection,SLOT(readyRead()),this,SIGNAL(gotData()));
connect(connection,SLOT(disconnected()),this,SIGNAL(onConnection()));
我得到的错误是:
Object::connect: Attempt to bind non-signal QTcpSocket::connected()
Object::connect: Attempt to bind non-signal QTcpSocket::readyRead()
Object::connect: Attempt to bind non-signal QTcpSocket::disconnected()
我找不到其他有同样问题的人。我在想这只是我正在做的愚蠢的事情。我在这个程序中的其他信号正在工作。
【问题讨论】:
-
语法是connect(sender,receiver),反之则不然。先有信号,然后是槽(或其他信号)。
标签: qt signals-slots