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. [Moved] Http request in QtNetwork
Forum Updated to NodeBB v4.3 + New Features

[Moved] Http request in QtNetwork

Scheduled Pinned Locked Moved Mobile and Embedded
5 Posts 2 Posters 2.9k Views 1 Watching
  • 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.
  • J Offline
    J Offline
    javiyt
    wrote on last edited by
    #1

    Hi, I have a problem with a simple HTTP request.

    It works fine with some networks, even if I'm not connected it gets the signal and complete the petition without error.

    But with some others, even when the browser is working, the petition emit a error signal.

    @
    QNetworkAccessManager qn;
    reply = qn.get(QNetworkRequest(QUrl("http://www.google.es")));

    // All the signals connections
    connect(...);
    @

    I tried with this example code from nokia

    @
    // Set Internet Access Point
    QNetworkConfigurationManager manager;

    const bool canStartIAP = (manager.capabilities() & QNetworkConfigurationManager::CanStartAndStopInterfaces);
    
    // Is there default access point, use it
    QNetworkConfiguration cfg = manager.defaultConfiguration();
    
    if (!cfg.isValid() || !canStartIAP) {
        // Available Access Points not found
        return;
    }
    
    // Open session
    m_session = new QNetworkSession(cfg);
    m_session->open();
    
    // Waits for session to be open and continues after that
    m_session->waitForOpened();
    qDebug() << m_session->state();
    

    @

    In the cases that it doesn't work it prints "1" that means QNetworkSession::NotAvailable.
    I don't know what I'm doing wrong.

    Thanks in advance.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on last edited by
      #2

      Looks like question is about mobile platforms? Moved to Mobile category from Quick.

      P.S. 2Moderators: if further discussion will reveal that question is about not only mobile platforms feel free to move it to general.

      1 Reply Last reply
      0
      • J Offline
        J Offline
        javiyt
        wrote on last edited by
        #3

        It's fine I usually post there because I work creating Qt Quick application, so I didn't check if there was a more specific forum about that topic. Sorry!

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DenisKormalev
          wrote on last edited by
          #4

          So it is mobile-related question, right?

          1 Reply Last reply
          0
          • J Offline
            J Offline
            javiyt
            wrote on last edited by
            #5

            Ahh yes, its about mobilephone. I didn't say it sorry.

            Well I found a solution, I don't know if it's the best but at least something...

            I leave it here just in case someone ask the same:

            @QNetworkConfigurationManager manager;
            QList<QNetworkConfiguration> activeConfigs = manager.allConfigurations(QNetworkConfiguration::Active);
            if(activeConfigs.count()) qnam.setConfiguration(activeConfigs.at(0));
            else qnam.setConfiguration(manager.defaultConfiguration());
            @

            qnam is suppose to be the qNetworkAccessManager

            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