QHttp signals don't work !!
I have a QHttp object.
Code:
http
= new QHttp("http://localhost",
80);
http->get("http://localhost/easyadvice/images/logo.jpg", 0);
.
.
.
connect(http, SIGNAL(readyRead()), this, SLOT(read()));
The console prints this message:
Object::connect: No such signal QHttp::readyRead()
What is wrong ?
Re: QHttp signals don't work !!
Quote:
Originally Posted by
probine
What is wrong ?
There is no such signal, try:
Re: QHttp signals don't work !!
The code:
Code:
http
= new QHttp("http://localhost",
80);
http->get("http://localhost/easyadvice/images/logo.jpg", 0);
.
.
.
void ChatUi::readLogo(){
tbLogo->append(logo);
}
It should append the logo to the QTextBrowser, why it is not there ?
Am I missing something else in the code ?
Re: QHttp signals don't work !!
QHttp::readyRead(const QHttpResponseHeader&):
Quote:
This signal is useful if you want to process the data in chunks as soon as it becomes available. If you are only interested in the complete data, just connect to the requestFinished() signal and read the data then instead.
So try using signal QHttp::requestFinished(int id, bool error) instead of readyRead().
Re: QHttp signals don't work !!
- Make sure your connection establishes. Try to launch in debug mode with CONFIG += console (if you are on Windows). Make sure it doesn't report signal-slot connection problems.
- Make sure readLogo() is defined as a slot in your header file.
- Make sure your file gets parsed by MOC.
- I'd suggest you to redesign you readLogo() to readLogo(const QHttpResponseHeader &). Inside of it you'd better check whether header.statusCode() == 200, which means successful reply.
WBR, Cesar
Re: QHttp signals don't work !!
I was using QHttp::requestFinished(int id, bool error)
Look at the code
Code:
connect(http, SIGNAL(requestFinished(int id, bool error)), this, SLOT(readLogo(int id, bool error)));
This is the console message:
Object::connect: No such signal QHttp::requestFinished(int id,bool error)
Please help !
Re: QHttp signals don't work !!
My program is working, so I added a tbLogo->append("hi"); to see if I even get here, but I don't.
Probably I am never even sending the request to the server.
What am I missing ?
Re: QHttp signals don't work !!
Quote:
Originally Posted by
probine
The code:
Code:
void ChatUi::readLogo(){
tbLogo->append(logo);
}
What you are doing here is reading the character data that is returned from the webserver. (At this point a QByteArray), and let Qt handle the transformation to a QString.
1) Handling binary data as ascii and transforming it to unicode (QString) is a bad idea, and probably not what you wanted.
2) You append this weirdly transformed piece of data to the textbrowser...
You will probably need to use some qimage function to actually transform that character data into a usable image. Which you then can (somehow) append to the textbrowser...
Re: QHttp signals don't work !!
Quote:
Originally Posted by
probine
Code:
connect(http, SIGNAL(requestFinished(int id, bool error)), this, SLOT(readLogo(int id, bool error)));
No variable names in SIGNAL or SLOT macros.
Re: QHttp signals don't work !!
Quote:
Originally Posted by
probine
My program is working, so I added a tbLogo->append("hi"); to see if I even get here, but I don't.
So by work, you mean compile?
Quote:
Originally Posted by
probine
Probably I am never even sending the request to the server.
If the webserver is really running locally, you can very easily check that by checking the access logs of said server, otherwise its very hard to say.
Re: QHttp signals don't work !!
Let's go one step back.
I am not even getting to the readLogo() function, I know it because the following function never prints anything in the QTextBrowser.
Code:
tbLogo->append("<html><table><tr><td>hi</td></tr></table></html>");
}
I guess I am not even sending the request, then please help me solving this issue first.
Re: QHttp signals don't work !!
Quote:
Originally Posted by
probine
I guess I am not even sending the request, then please help me solving this issue first.
Are you starting the request? (Some qDebug output can do wonders)
Is your webserver logging some access?
Is there any warning output regarding signals not connected?
You might want to see if you get the requestStarted signal.
If nothing works, post a minimal compilable example...