Hello! I am trying to detect when I lose connection to Internet, for example when I cannot load any site or any application that connects to Internet.
I am trying this with QNetworkAccesManager but signal networkAccessibleChanged never gets called.
My code:
{
this->setGeometry(400, 400, 400, 400);
manager = new QNetworkConfigurationManager();
pManager->setConfiguration(manager->defaultConfiguration());
connect(pManager, &QNetworkAccessManager::networkAccessibleChanged, this, &mainWindow::test);
}
void mainWindow::test(QNetworkAccessManager::NetworkAccessibility access){
qDebug() << access;
}
mainWindow::mainWindow(QWidget *parent) : QWidget(parent)
{
this->setGeometry(400, 400, 400, 400);
manager = new QNetworkConfigurationManager();
pManager->setConfiguration(manager->defaultConfiguration());
connect(pManager, &QNetworkAccessManager::networkAccessibleChanged, this, &mainWindow::test);
}
void mainWindow::test(QNetworkAccessManager::NetworkAccessibility access){
qDebug() << access;
}
To copy to clipboard, switch view to plain text mode
How can I solve this? Thank you!
Bookmarks