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())
{
break;
break;
}
proxy->setHostName(leProxyHost->text());
proxy->setPort(sbProxyPort->value());
proxy->setUser(leProxyUsername->text());
proxy->setPassword(leProxyPassword->text());
}
else
for (engine = engines.constBegin(); engine != engines.constEnd(); ++engine)
(*engine)->setProxy(proxy);
}
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);
}
To copy to clipboard, switch view to plain text mode
"proxy" is a "QNetworkProxy *" internal object of MainWidget. It's initialized in this way:
proxy = new QNetworkProxy(QNetworkProxy::NoProxy);
To copy to clipboard, switch view to plain text mode
All "engines" have no proxy configuration at all, but one, and it executes the following code:
{
sizeRequest.setProxy(*newProxy);
searchRequest.setProxy(*newProxy);
photoInfoRequest.setProxy(*newProxy);
photoDownload.setProxy(*newProxy);
}
void Flickrs::setProxy(const QNetworkProxy *newProxy)
{
sizeRequest.setProxy(*newProxy);
searchRequest.setProxy(*newProxy);
photoInfoRequest.setProxy(*newProxy);
photoDownload.setProxy(*newProxy);
}
To copy to clipboard, switch view to plain text mode
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.
Bookmarks