Results 1 to 2 of 2

Thread: QNetworkProxy

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2008
    Location
    Italy
    Posts
    20
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QNetworkProxy

    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.

    Qt Code:
    1. void MainWidget::updateProxy()
    2. {
    3. QList<Engine *>::const_iterator engine;
    4.  
    5. if (rbProxyConnection->isChecked())
    6. {
    7. switch (cbProxyType->currentIndex())
    8. {
    9. case 0: proxy->setType(QNetworkProxy::HttpProxy);
    10. break;
    11.  
    12. case 1: proxy->setType(QNetworkProxy::Socks5Proxy);
    13. break;
    14. }
    15.  
    16. proxy->setHostName(leProxyHost->text());
    17. proxy->setPort(sbProxyPort->value());
    18. proxy->setUser(leProxyUsername->text());
    19. proxy->setPassword(leProxyPassword->text());
    20. }
    21. else
    22. proxy->setType(QNetworkProxy::NoProxy);
    23.  
    24. for (engine = engines.constBegin(); engine != engines.constEnd(); ++engine)
    25. (*engine)->setProxy(proxy);
    26. }
    To copy to clipboard, switch view to plain text mode 
    "proxy" is a "QNetworkProxy *" internal object of MainWidget. It's initialized in this way:

    Qt Code:
    1. 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:

    Qt Code:
    1. void Flickrs::setProxy(const QNetworkProxy *newProxy)
    2. {
    3. sizeRequest.setProxy(*newProxy);
    4. searchRequest.setProxy(*newProxy);
    5. photoInfoRequest.setProxy(*newProxy);
    6. photoDownload.setProxy(*newProxy);
    7. }
    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.
    Last edited by jpn; 29th June 2008 at 18:31. Reason: missing [code] tags

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.