Can someone please explain why on God's green earth the network classes __need__ GUI QWidget resources?
What makes you think they do? QtNetwork4 is not dependent on QtGui4 on my machine.
This makes them completely unusable from a console app.
Really? This program compiles and runs fine without Gui:
#include <QtCore>
#include <QtNetwork>
#include <QDebug>
Q_OBJECT
public:
void fetch
(const QUrl &url
) { reply = nam.get(QNetworkRequest(url));
connect(reply, SIGNAL(finished()), SLOT(slotFinished()));
}
public slots:
void slotFinished() {
qDebug() << Q_FUNC_INFO << "Error" << reply->error();
qDebug() << ba;
reply->deleteLater();
emit finished();
}
signals:
void finished();
private:
QNetworkAccessManager nam;
QNetworkReply *reply;
};
int main(int argc, char *argv[])
{
Fetcher f;
f.
fetch(QUrl("http://www.qtcentre.org/robots.txt"));
QObject::connect(&f,
SIGNAL(finished
()),
qApp,
SLOT(quit
()));
return app.exec();
}
#include "main.moc"
#include <QtCore>
#include <QtNetwork>
#include <QDebug>
class Fetcher: public QObject {
Q_OBJECT
public:
Fetcher(QObject *p = 0): QObject(p), reply(0) {}
void fetch(const QUrl &url) {
reply = nam.get(QNetworkRequest(url));
connect(reply, SIGNAL(finished()), SLOT(slotFinished()));
}
public slots:
void slotFinished() {
qDebug() << Q_FUNC_INFO << "Error" << reply->error();
QByteArray ba = reply->readAll();
qDebug() << ba;
reply->deleteLater();
emit finished();
}
signals:
void finished();
private:
QNetworkAccessManager nam;
QNetworkReply *reply;
};
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
Fetcher f;
f.fetch(QUrl("http://www.qtcentre.org/robots.txt"));
QObject::connect(&f, SIGNAL(finished()), qApp, SLOT(quit()));
return app.exec();
}
#include "main.moc"
To copy to clipboard, switch view to plain text mode
It has "QT -= gui" in the PRO file and is consequently not linked to QtGui4.
Plenty of people have filed bugs. This is not a bug though.
Bookmarks