Тупой вопрос по Qt5:
#include <QObject>
#include <QTcpServer>
#include <stdio.h>
#include <unistd.h>
class x : public QObject
{
QTcpServer *tcpServer;
public:
x(QObject *parent = 0) : QObject(parent)
{
tcpServer = new QTcpServer(this);
}
bool init(const QString &host, const qint16 port)
{
bool rc;
connect(tcpServer, SIGNAL(newConnection()), this, SLOT(slotNewUser()));
if (host.isEmpty() == true)
{
rc = tcpServer->listen(QHostAddress::Any, port);
}
else
{
rc = tcpServer->listen(QHostAddress(host), port);
}
return rc;
}
public slots:
void slotNewUser()
{
printf("slotNewUser()\n"); fflush(stdout);
}
};
int main(int argc, char *argv[])
{
x xxx;
if (xxx.init("", 8001) == false)
{
printf("ERROR[listen()]: failed\n");
return 1;
}
sleep(60);
return 0;
}
Компилю так:
g++ test.cpp -o test -fPIC -lQt5Concurrent -lQt5Core -lQt5DBus -lQt5Gui -lQt5Network -lQt5OpenGL -lQt5PrintSupport -lQt5Script -lQt5ScriptTools -lQt5Sql -lQt5Test -lQt5V8 -lQt5Widgets -lQt5Xml -I/usr/include/qt5/ -I/usr/include/qt5/QtNetwork/ -I/usr/include/qt5/QtCore/
запускаю и получаю: QObject::connect: No such slot QObject::slotNewUser() in test.cpp:25
как это лечить?