WiFi List
-
I'm using QT6.7, and I trying get a list of the wifi connections available. But I not find any example, just ones with deprecated classes from before QT6.
I found the classes QNetworkAccessManager and QNetworkInformation in subdir QtNetwork, but I don't know how used it.
Any easy way to do it?
Thanks -
Hi,
AFAIK, there's no such functionality.
QNAM is for making request and QNetworkInformation is for getting information about the current active network connection.
If you really need that kind of low level information, you should check your platform API. -
I'm using QT6.7, and I trying get a list of the wifi connections available. But I not find any example, just ones with deprecated classes from before QT6.
I found the classes QNetworkAccessManager and QNetworkInformation in subdir QtNetwork, but I don't know how used it.
Any easy way to do it?
Thanks@Cesar-Olesk Hi, this is not supported.
You can get existing interfaces using QNetworkInterface class but can't manipulate them.
You should use, as suggested, native platform API in order to achieve your goal. Please bear in mind that on certain platforms in certain configurations any such action might require running your software with elevated privileges. -
Hi, I am trying to implement the same thing. What I am doing is using qtdbus to communicate with the IWD. In the same way, one can use another service like wpa_supplicant.
This is some tests I am doing
#include <QDBusArgument> #include <QDBusConnection> #include <QDBusInterface> int main(int argc, char *argv[]) { QCoreApplication app(argc, argv); auto connection = QDBusConnection::systemBus(); QDBusInterface iwdStation("net.connman.iwd", "/net/connman/iwd/0/4", "net.connman.iwd.Station", connection); if (iwdStation.isValid()) { qDebug() << "is valid " << iwdStation.property("State").isValid(); auto message = iwdStation.call("GetOrderedNetworks"); qDebug() << "message:" << message; auto args = message.arguments(); qDebug() << "args:" << args; for (const auto &arg : args) { const auto argsI = arg.value<QDBusArgument>(); QDBusObjectPath opath; qint16 strenght; argsI.beginMap(); while (!argsI.atEnd()) { argsI.beginMapEntry(); argsI >> opath >> strenght; argsI.endMapEntry(); qDebug() << opath.path() << " " << strenght; QDBusInterface network("net.connman.iwd", opath.path(), "net.connman.iwd.Network", connection); qDebug() << "network Name: " << network.property("Name").toString() << "\n" << network.property("Connected").toBool() << "\n" << network.property("Type").toString(); } argsI.endMap(); } } return app.exec(); }
This gives me the available networks. Still, there is much room for improvement.