我使用Axis Communications的两台ip摄像头作为我的应用程序。我想检查相机是否断开连接。是否可以使用QNetworkAccessManager
和QNetworkReply
来完成此操作?
我尝试过的原型如下:
QNetworkAccessManager *m_networkAccessManager = new QNetworkAccessManager();
QNetworkReply *m_networkReply = m_networkAccessManager->get(QNetworkRequest(camUrl));
if (!m_networkReply)
{
delete m_networkAccessManager;
qDebug()<<"Camera not found"<<endl;
}
connect(m_networkReplyCam, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(cameraDisconnected(QNetworkReply::NetworkError)));
void MainWindow::cameraDisconnected(QNetworkReply::NetworkError)
{
qDebug()<<"Camera Disconected"<<endl;
}
但是似乎永远不会调用插槽cameraDisconnected
。我还尝试连接来自finished()
的{{1}}信号,如下所示:
QNetworkReply
但即使这样,插槽也永远不会被调用。
我做错了什么?
感谢。