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. Usage of specific QNetworkConfiguration on android
Forum Updated to NodeBB v4.3 + New Features

Usage of specific QNetworkConfiguration on android

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 190 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.
  • J Offline
    J Offline
    JohnAmadis
    wrote on last edited by
    #1

    Hi,

    I work on android application that needs to connect to a server in a WLAN. The problem is that this WLAN does not have internet access, so on some devices it is not set as default network configuration in QNetworkAccessManager::activeConfiguration()

    I found the required config in QNetworkConfigurationManager::allConfigurations() but I dont have an idea how can I force QTcpSocket to use this instead of the default one. I tried to do this for example in this way:
    (Sorry for the ugly code - it is just for test as I am currently looking for some solution)

    QNetworkConfigurationManager configurationsManager;
                auto configurations = configurationsManager.allConfigurations();
                for ( auto config : configurations )
                {
                    auto b = config.bearerType();
                    if ( b == QNetworkConfiguration::BearerWLAN )
                    {
                        auto networkSession = new QNetworkSession( currentConfiguration );
                        networkSession->open();
                        networkSession->waitForOpened();
                        QNetworkConfiguration config = networkSession->configuration();
                        QString id;
                        if (config.type() == QNetworkConfiguration::UserChoice)
                            id = networkSession->sessionProperty(QLatin1String("UserChoiceConfiguration")).toString();
                        else
                            id = config.identifier();
    
                        QSettings settings(QSettings::UserScope, QLatin1String("QtProject"));
                        settings.beginGroup(QLatin1String("QtNetwork"));
                        settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id);
                        settings.endGroup();
                        break;
                    }
                }
    

    But it did not help at all... Do you know how can I change the active configuration or pass it to the QTcpSocket to force it to use this interface?

    Best Regards,
    Patryk

    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