Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can I connect to wifi using QT

How can I connect to wifi using QT

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 1.2k Views 3 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.
  • S Offline
    S Offline
    Sanskar
    wrote on last edited by
    #1

    Hello I'm trying to connect to wifi using following code.

    QNetworkConfiguration cfg;
    QNetworkConfigurationManager ncm;
    auto nc = ncm.allConfigurations();

    for (auto &x : nc)
    {
    if (x.bearerType() == QNetworkConfiguration::BearerWLAN)
    {
    qDebug() << x.name();
    if (x.name() == "YouDesiredNetwork")
    cfg = x;
    }
    }
    auto session = new QNetworkSession(cfg, this);
    session->open();

    but is not connecting to network
    also in ubuntu it gives me list of wifi network but when I run this in windows it is showing me below output(I have 5 available networks)
    output: -
    "Wi-Fi"
    "Local Area Connection* 9"

    jsulmJ 1 Reply Last reply
    0
    • Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #2

      The simplest solution is often the correct one.

      Are you sure the WIFI profiles have the correct key stored in them?
      What does the error code state() of session indicate?

      The dystopian literature that served as a warning in my youth has become an instruction manual in my elder years.

      1 Reply Last reply
      0
      • S Sanskar

        Hello I'm trying to connect to wifi using following code.

        QNetworkConfiguration cfg;
        QNetworkConfigurationManager ncm;
        auto nc = ncm.allConfigurations();

        for (auto &x : nc)
        {
        if (x.bearerType() == QNetworkConfiguration::BearerWLAN)
        {
        qDebug() << x.name();
        if (x.name() == "YouDesiredNetwork")
        cfg = x;
        }
        }
        auto session = new QNetworkSession(cfg, this);
        session->open();

        but is not connecting to network
        also in ubuntu it gives me list of wifi network but when I run this in windows it is showing me below output(I have 5 available networks)
        output: -
        "Wi-Fi"
        "Local Area Connection* 9"

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @Sanskar What about connecting slots to https://doc.qt.io/qt-5/qnetworksession.html#error-1 and https://doc.qt.io/qt-5/qnetworksession.html#stateChanged and checking https://doc.qt.io/qt-5/qnetworksession.html#errorString and state there?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1

        • Login

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