diff options
author | Jannis Voelker <jannis.voelker@basyskom.com> | 2019-01-11 08:44:18 +0100 |
---|---|---|
committer | Jannis Völker <jannis.voelker@basyskom.com> | 2019-01-11 13:46:15 +0000 |
commit | 0a2e60908577e56caf3c4d94ebd5492f2eb828e3 (patch) | |
tree | b29afdbd60722011b8d86a1d0d9b7c0cf3e228a7 /examples | |
parent | 95ceb8788a954044b95fc0b9357950f76852d84a (diff) |
opcuaviewer: Wait for the namespaces array
If a server uses the namespace URI for local results in the
browse response, the namespaces array must be available before
the browse results can be used.
Change-Id: I4cd7ca76f9b06089f2b3361ad75eb8077063c60c
Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/opcua/opcuaviewer/mainwindow.cpp | 17 | ||||
-rw-r--r-- | examples/opcua/opcuaviewer/mainwindow.h | 1 |
2 files changed, 16 insertions, 2 deletions
diff --git a/examples/opcua/opcuaviewer/mainwindow.cpp b/examples/opcua/opcuaviewer/mainwindow.cpp index 8c6bf69..c995e1c 100644 --- a/examples/opcua/opcuaviewer/mainwindow.cpp +++ b/examples/opcua/opcuaviewer/mainwindow.cpp @@ -324,8 +324,9 @@ void MainWindow::clientConnected() { mClientConnected = true; updateUiState(); - mOpcUaModel->setOpcUaClient(mOpcUaClient); - mTreeView->header()->setSectionResizeMode(1 /* Value column*/, QHeaderView::Interactive); + + connect(mOpcUaClient, &QOpcUaClient::namespaceArrayUpdated, this, &MainWindow::namespacesArrayUpdated); + mOpcUaClient->updateNamespaceArray(); } void MainWindow::clientDisconnected() @@ -337,6 +338,18 @@ void MainWindow::clientDisconnected() updateUiState(); } +void MainWindow::namespacesArrayUpdated(const QStringList &namespaceArray) +{ + if (namespaceArray.isEmpty()) { + qWarning() << "Failed to retrieve the namespaces array"; + return; + } + + disconnect(mOpcUaClient, &QOpcUaClient::namespaceArrayUpdated, this, &MainWindow::namespacesArrayUpdated); + mOpcUaModel->setOpcUaClient(mOpcUaClient); + mTreeView->header()->setSectionResizeMode(1 /* Value column*/, QHeaderView::Interactive); +} + void MainWindow::clientError(QOpcUaClient::ClientError error) { qDebug() << "Client error changed" << error; diff --git a/examples/opcua/opcuaviewer/mainwindow.h b/examples/opcua/opcuaviewer/mainwindow.h index 80e7c64..d7056d1 100644 --- a/examples/opcua/opcuaviewer/mainwindow.h +++ b/examples/opcua/opcuaviewer/mainwindow.h @@ -80,6 +80,7 @@ private slots: void getEndpointsComplete(const QVector<QOpcUa::QEndpointDescription> &endpoints, QOpcUa::UaStatusCode statusCode); void clientConnected(); void clientDisconnected(); + void namespacesArrayUpdated(const QStringList &namespaceArray); void clientError(QOpcUaClient::ClientError); void clientState(QOpcUaClient::ClientState); void showErrorDialog(QOpcUaErrorState *errorState); |