Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QNetworkAccessManager on iOS?
QtWS25 Last Chance

QNetworkAccessManager on iOS?

Scheduled Pinned Locked Moved Mobile and Embedded
3 Posts 2 Posters 1.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    k.gaitanis
    wrote on last edited by
    #1

    I'm writting an iPhone app that uses QNetworkAccessManager to download some images from the internet. The following code works on the desktop : The file is downloaded and a list of several configurations are displayed. However on the iPhone no network configurations are found and the file is not downloaded. networkAccessible() returns NotAccessible.

    How can I make QNetworkAccessManager work on iOS? Are there any libs/capabilities that I have to include/activate in my .pro file? Any special configuration from the side of XCode?

    According to https://codereview.qt-project.org/#change,69298 there should be a NSUrlConnection backend available for iOS but I can't find any instructions on setting it up.

    Any help would be greatly appreciated. Thanks

    @void main() {
    QCoreApplication app;
    // only one nam instance in my app
    QNetworkAccessManager* nam = new QNetworkAccessManager();
    connect (nam, SIGNAL(finished(QNetworkReply*)), receiver, SLOT(onFinished(QNetworkReply*)));

    app.exec();
    

    }

    // this is called from inside the event loop
    void fetch() {
    foreach (QNetworkConfiguration config, nam->allConfigurations()) {
    qDebug() << config.name();
    }

    QUrl url("http://..../A.png");
    nam->get(QNetworkRequest(url));
    

    }

    // this is the receiver's slot
    void onFinished(QNetworkReply* reply) {
    doSomething();
    }@

    Qt 5.2 | iOS 7.0 on iPhone5

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Vincent007
      wrote on last edited by
      #2

      You can try Qt examples involving QNetworkAccessManager.

      By the way, please check the network connection of your iOS device.

      1 Reply Last reply
      0
      • K Offline
        K Offline
        k.gaitanis
        wrote on last edited by
        #3

        Thanks for your quick answer. Problem solved. There was nothing wrong with the code of course. I simply had to enable the network link conditioner in the Developer menu of my iPhone. Thanks for pointing that out.

        QNetworkAccessManager works like a charm on iOS !

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved