问一个关于qt制作http服务器的问题,添加了库之后具体要怎么调用啊,求解
三只猴子 2018-03-15 03:14:31 我添加了qhttpserve的库,看网上的测试程序如下:
HelloWorld::HelloWorld()
{
QHttpServer *server = new QHttpServer(this);
connect(server, SIGNAL(newRequest(QHttpRequest*, QHttpResponse*)),
this, SLOT(handleRequest(QHttpRequest*, QHttpResponse*)));
server->listen(QHostAddress::Any, 8080);
}
void HelloWorld::handleRequest(QHttpRequest *req, QHttpResponse *resp)
{
Q_UNUSED(req);
QByteArray body = "Hello World";
resp->setHeader("Content-Length", QString::number(body.size()));
resp->writeHead(200);
resp->end(body);
}
/// main
int main(int argc, char **argv)
{
QCoreApplication app(argc, argv);
HelloWorld hello;
app.exec();
}
请问下这个具体是怎么调用的啊,我想要用这个服务器通过http接收和发送数据,要怎么调用