Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QNetworkConfigurationManager deprecated



  • Hello,
    I want to scan wifi configuration of my computer to create an auto login program I was found this code:

    QNetworkConfigurationManager ncm;
    
            QList<QNetworkConfiguration> netcfgList = ncm.allConfigurations();
            for (QNetworkConfiguration &x : netcfgList)
            {
                if (x.bearerType() == QNetworkConfiguration::BearerWLAN && x.state() == QNetworkConfiguration::Defined)
                {
                     qDebug() <<x.name()<< x.type();
    
    
                }
            }
    

    This code work but I have recently upgraded my qt to 15.1.1 and it show me deprecated warning.
    What can I use in Qt 15.1.1 to do the same thing?
    My goal is only detect the current wifi's SSID.

    Thanks in advance.


  • Qt Champions 2019



  • Thanks but, I want to get a way to get the name of Wifi hotpost where my computer is connected.
    I want to create a program that detect conexion portal and connect to to the portal if it have it on a db.
    Now, it have functional db, it can detect the portal and connect to it. My only one problem is detect that the computer is connected to wifi and then detect the wifi name to try to connect to the right portal.
    I don't want to use qprocess because this app will be instaled on a phone, or on a computer with windows or linux.


  • Qt Champions 2019

    I don't understand the problem. What's wrong with e.g. QNetworkInterface::humanReadableName() then?



  • this code

    QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces();
    
        for (QNetworkInterface i : interfaces){
            qDebug()<<i.name()<<i.flags()<<i.humanReadableName();
        }
    

    return

    "lo" QFlags<QNetworkInterface::InterfaceFlag>(IsUp|IsRunning|IsLoopBack) "lo"
    "enp1s0" QFlags<QNetworkInterface::InterfaceFlag>(CanBroadcast|CanMulticast) "enp1s0"
    "wlp2s0" QFlags<QNetworkInterface::InterfaceFlag>(IsUp|IsRunning|CanBroadcast|CanMulticast) "wlp2s0"
    

    But I want the name of the Wifi in my case "Livebox-29d9"
    My problem is that this code:

    QNetworkConfigurationManager ncm;
    
            QList<QNetworkConfiguration> netcfgList = ncm.allConfigurations();
            for (QNetworkConfiguration &x : netcfgList)
            {
                if (x.bearerType() == QNetworkConfiguration::BearerWLAN && x.state() == QNetworkConfiguration::Active)
                {
                     qDebug() <<x.name();
    
    
                }
            }
    

    is deprecated.


  • Qt Champions 2019

    Ok, then you either have to stay with Qt5.15 or write it by your own.


Log in to reply