Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Connection issue OPC UA
Forum Updated to NodeBB v4.3 + New Features

Connection issue OPC UA

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 306 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    athyc
    wrote on last edited by
    #1

    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();
    }
    
    aha_1980A 1 Reply Last reply
    0
    • A athyc

      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();
      }
      
      aha_1980A Offline
      aha_1980A Offline
      aha_1980
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @athyc probably because most Qt communication classes need the Qt event loop a.exec() to be running. You'll need to refactor your app so a.exec() is running before you start your OPC communication.

      Regards

      Qt has to stay free or it will die.

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved