Unsolved Connection issue OPC UA
-
Why is it this stalls on connecting?
#include <QCoreApplication>
#include "QOpcUaProvider"
#include <QtOpcUa/QOpcUaClient>
#include <QUrl>
#include <QString>
#include <string>#include <iostream>
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);QOpcUaProvider provider; if(provider.availableBackends().isEmpty()){ return a.exec(); } QOpcUaClient *client = provider.createClient(provider.availableBackends()[0]); if(!client){ return a.exec(); } QUrl OpcUa_server("opc.tcp://10.10.0.1:4840"); if(client->requestEndpoints(OpcUa_server) == true){ client->connectToEndpoint(OpcUa_server); }else{ return a.exec(); }
-
@athyc probably because most Qt communication classes need the Qt event loop
a.exec()
to be running. You'll need to refactor your app soa.exec()
is running before you start your OPC communication.Regards