I need to disconnect from current access point. I wrote this piece of code:
QNetworkConfigurationManager manager;
QNetworkConfiguration cfg = manager.defaultConfiguration();
// Open session
m_session = new QNetworkSession(cfg);
m_session->open();
m_session->waitForOpened();
How can I disconnect from wifi? Or should I use C/C++ (some API) for that?
You can use QProcess and run system commands to connect and disconnect WiFi like below but this is Linux solution:
QProcess *system_command = new QProcess();
system_command->start("/bin/bash");
system_command->waitForFinished(500);
system_command->write("nmcli d disconnect wlp3s0\n");
Replace wlp3s0 with your WiFi interface name. You can find your connected WiFi interface name with
nmcli c
and you can connect your WiFi again with:
nmcli d connect wlp3s0
For more info check this.