PDA

View Full Version : Signals and Slots and HTTP



weaver4
11th January 2010, 18:00
I am getting this error when I run my code:

URL.Host = edition.cnn.com
URL.Path = /services/podcasting/newscast/rss.xml
Object::connect: No such slot PodcastFeed::FeedReadData(const QHttpResponseHeader &) in podcastfeed.cpp:25
Object::connect: No such slot PodcastFeed::FeedRequestFinished( int, bool) in podcastfeed.cpp:26
ConnectionId = 2
(Internal error: pc 0x6241a0 in read in psymtab, but not in symtab.)
(Internal error: pc 0x6241a0 in read in psymtab, but not in symtab.)
(Internal error: pc 0x6241a1 in read in psymtab, but not in symtab.)
(Internal error: pc 0x6241a0 in read in psymtab, but not in symtab.)
(Internal error: pc 0x6241a0 in read in psymtab, but not in symtab.)

Can someone give me a hand I am using QTCreator and QT 4.6.

Here is my header:



#ifndef PODCASTFEED_H
#define PODCASTFEED_H
#include <QObject>
#include <QString>
#include <QtNetwork>
#include <QHttp>

class PodcastFeed : public QObject
{
Q_OBJECT

public:
PodcastFeed();
int id;
QString title;
QString description;
QString url;
QString action;
int actionInt;
int sortOrder;

QString feedTitle;
QString feedDescription;

void Load();
void DownloadFeed(QString url);
void FeedReadData(const QHttpResponseHeader &resp);
void FeedRequestFinished( int id, bool error);



private:
bool completed;
int connectionId;
QHttp http;
QXmlStreamReader xml;
void ParseXml();
};
#endif // PODCASTFEED_H


and here is the function I am having difficulty with.



void PodcastFeed::DownloadFeed(QString url)
{
xml.clear();
QUrl myUrl(url);
http.setHost(myUrl.host());
Util::WriteLine("URL.Host = " + myUrl.host());
Util::WriteLine("URL.Path = " + myUrl.path());

QObject::connect(&http, SIGNAL(readyRead(const QHttpResponseHeader &)), this, SLOT(FeedReadData(const QHttpResponseHeader &)));
QObject::connect(&http, SIGNAL(requestFinished( int, bool)), this, SLOT(FeedRequestFinished( int, bool)));
connectionId = http.get(myUrl.path());
Util::WriteLine("ConnectionId = " + QString::number(connectionId));
// Proceeds to FeedReadData when read.
}

void PodcastFeed::FeedRequestFinished( int id, bool error)
{
Util::WriteLine("GotRequestFinished");
}

void PodcastFeed::FeedReadData(const QHttpResponseHeader &resp)
{
Util::WriteLine("FeedReadData");
if (resp.statusCode() != 200)
http.abort();
else {
xml.addData(http.readAll());
ParseXml();
}
}

squidge
11th January 2010, 19:56
I don't see how much plainer the error could be. It telling you that you have no such slot FeedReadData & FeedRequestFinished, which is absolutely correct, as you don't.

If the ones with the same name in your class are meant to be slots, then you need to describe them as such by using the "slots" keyword.



slots:
void FeedReadData(const QHttpResponseHeader &resp);
void FeedRequestFinished( int id, bool error);

weaver4
11th January 2010, 20:21
Thanks, I missed this. I am new to QT.

squidge
11th January 2010, 22:44
If your new to Qt (It's Qt, not QT, as it's not an abbreviation), then you should really be posting in the "Newbie" section, not the "more advanced Qt" section.