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. Qnetwork Manager show available SSID's

Qnetwork Manager show available SSID's

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 450 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.
  • M Offline
    M Offline
    Markus Ippy
    wrote on last edited by
    #1

    i am trying to use QNetwork to scan for available WLAN SSID's

    Here is my test programm that just outputs debug messages for now . The main aim was to show which Wifi networks are in range on Linux.
    I have a few issues :
    On Linux :
    Bearer Type for wlan0 and eth0 is shown as 1 (Ethernet) , i was expecting it to be 2 (WLan) for wlan0

    i was under the impression that x.name would give me the SSID's whats the correct command to get the SSiD's )

    main.cpp :

    #include "mainwindow.h"
    #include <QApplication>
    
    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    return a.exec();
    }
    

    my mainwindow.cpp :

    #include "mainwindow.h"
    #include <QDebug>
    
    MainWindow::MainWindow(QWidget *parent)
    : QWidget(parent)
    {
    
    findTimer = new QTimer();
    findTimer->setInterval(1000);
    connect(findTimer,&QTimer::timeout,this,&MainWindow::findActiveWirelesses);
    findTimer->start();
    foundCount = 0;
    findActiveWirelesses();
    }
    
    void MainWindow::findActiveWirelesses()
    {
    QNetworkConfigurationManager ncm;
    netcfgList = ncm.allConfigurations();
    WiFisList.clear();
    for (auto &x : netcfgList)
    {
        qDebug() << "Type:" << x.bearerType() << "Name: " << x.name();
        // on Linux This returns :
        //              Type: 1 Name:  "eth0"
        //              Type: 1 Name:  "wlan0"
        
        // on Windows This returns :
        //              Type: 0 Name:  "Celluar"
        //              Type: 1 Name:  "Ethernet"
        if (x.bearerType() == QNetworkConfiguration::BearerWLAN)
        {
            //This does nothing as the bearerType stays 1 on linux and 0 or 1 on Windows
            if(x.name() == "")
                WiFisList << "Unknown(Other Network)";
            else
                WiFisList << x.name();
        }
    }
    for(int i=0; i<WiFisList.size(); i++)
    {
        bool exist = false;
        qDebug() << "Show wifi List size " << WiFisList.size();
       
    }
    }
    

    mainwindow.h :

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QWidget>
    #include <QTimer>
    #include <QList>
    #include <QInputDialog>
    #include <QStandardItem>
    #include <QStandardItemModel>
    #include <QNetworkConfiguration>
    #include <QNetworkConfigurationManager>
    #include <QNetworkSession>
    
    class MainWindow : public QWidget
    {
    Q_OBJECT
    
    public:
    explicit MainWindow(QWidget *parent = 0);
    
    int foundCount;
    QNetworkConfiguration netcfg;
    QStringList WiFisList;
    QList<QNetworkConfiguration> netcfgList;
    
    public slots:
    void findActiveWirelesses();
    
    
    private:
    
    QTimer *findTimer;
    QStandardItemModel* listModel;
    QNetworkSession *session;
    };
    
    #endif // MAINWINDOW_H
    
    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