PDA

View Full Version : QNetworkProxy



becrux
29th June 2008, 19:18
Hi everybody,

I'm fighting with QNetworkProxy all day, without solving my issue.

I commented step-by-step pieces of code all day, and at the end I found out that I cannot initialize my QHttp objects with QNetworkProxy correctly.

Briefly, my app starts, initialize widgets, it loads settings, and of course proxy settings.


void MainWidget::updateProxy()
{
QList<Engine *>::const_iterator engine;

if (rbProxyConnection->isChecked())
{
switch (cbProxyType->currentIndex())
{
case 0: proxy->setType(QNetworkProxy::HttpProxy);
break;

case 1: proxy->setType(QNetworkProxy::Socks5Proxy);
break;
}

proxy->setHostName(leProxyHost->text());
proxy->setPort(sbProxyPort->value());
proxy->setUser(leProxyUsername->text());
proxy->setPassword(leProxyPassword->text());
}
else
proxy->setType(QNetworkProxy::NoProxy);

for (engine = engines.constBegin(); engine != engines.constEnd(); ++engine)
(*engine)->setProxy(proxy);
}

"proxy" is a "QNetworkProxy *" internal object of MainWidget. It's initialized in this way:


proxy = new QNetworkProxy(QNetworkProxy::NoProxy);

All "engines" have no proxy configuration at all, but one, and it executes the following code:


void Flickrs::setProxy(const QNetworkProxy *newProxy)
{
sizeRequest.setProxy(*newProxy);
searchRequest.setProxy(*newProxy);
photoInfoRequest.setProxy(*newProxy);
photoDownload.setProxy(*newProxy);
}

Of course, sizeRequest and all others are QHttp objects.

If I don't comment this code, it produces the following output:


QColor::setSystemNamedColor: Cannot perform this operation because QApplication does not exist
Floating point exception

while, if it's empty, everything is fine and my app is usable.

I really cannot understand the meaning of the error code. QColor?? Why?

Can you provide me some suggestions? I'm really lost :(

Thank you so much.

Tony.

becrux
29th June 2008, 22:40
This time I succeeded myself :)

Anytime proxy is configured via SetProxy, done() signal (and I guess many other before) is fired. So, all my code was launched behind the scene, when it did not have to be.

Well, some words in the documentation would be very appreciated :cool:

Thanks a lot anyway,

Tony.