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. QTOpcUa -- connectToEndPoint Error
Forum Updated to NodeBB v4.3 + New Features

QTOpcUa -- connectToEndPoint Error

Scheduled Pinned Locked Moved Unsolved General and Desktop
opcuaclient
6 Posts 4 Posters 1.2k 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.
  • T Offline
    T Offline
    TMJJ001
    wrote on last edited by TMJJ001
    #1

    Dear all,

    I'm probably doing something stupid. I'm trying the first time to connect to OPC UA server.
    I'm following the below tutorial from QT:
    https://www.youtube.com/watch?v=p4MNmzkxsq0&t=2109s

    @ 30 min he is writting :

    m_client->connectToEndpoint(QUrl("opc.tcp://localhost:4840"));
    

    When I try to, I always get the next error:

    error: no viable conversion from 'QUrl' to 'const QOpcUaEndpointDescription'
    

    Can somebody explain me what could be wrong? So I can learn from it?
    Below the code .

    #ifndef MACHINESTATE_H
    #define MACHINESTATE_H
    
    #include <QObject>
    #include <QScopedPointer>
    #include <QtOpcUa>
    
    class machinestate : public QObject
    {
        Q_OBJECT
    public:
        explicit machinestate(QObject *parent = nullptr);
    
    
    signals:
    
    public slots:
        void onStateChanged(QOpcUaClient::ClientState state);
    
    private:
        QScopedPointer<QOpcUaClient> m_client;
        QScopedPointer<QOpcUaNode> m_statusNode;
    };
    
    #endif // MACHINESTATE_H
    
    
    #include "machinestate.h"
    #include <QDebug>
    #include <QUrl>
    
    machinestate::machinestate(QObject *parent) : QObject(parent)
    {
    
        QOpcUaProvider provider;
        qDebug() << provider.availableBackends();
    
        m_client.reset(provider.createClient("open62541"));
        qDebug() << m_client.data();
    
        connect(m_client.data(), &QOpcUaClient::stateChanged, this, &machinestate::onStateChanged);
    
        m_client->connectToEndpoint(QUrl("opc.tcp://localhost:4840"));
    
    }
    
    void machinestate::onStateChanged(QOpcUaClient::ClientState state)
    {
        qDebug() << state;
    }
    
    
    

    I'm using Qt5.13.0.

    Thanks in advance,
    Kind regards.

    jsulmJ 1 Reply Last reply
    0
    • T TMJJ001

      Dear all,

      I'm probably doing something stupid. I'm trying the first time to connect to OPC UA server.
      I'm following the below tutorial from QT:
      https://www.youtube.com/watch?v=p4MNmzkxsq0&t=2109s

      @ 30 min he is writting :

      m_client->connectToEndpoint(QUrl("opc.tcp://localhost:4840"));
      

      When I try to, I always get the next error:

      error: no viable conversion from 'QUrl' to 'const QOpcUaEndpointDescription'
      

      Can somebody explain me what could be wrong? So I can learn from it?
      Below the code .

      #ifndef MACHINESTATE_H
      #define MACHINESTATE_H
      
      #include <QObject>
      #include <QScopedPointer>
      #include <QtOpcUa>
      
      class machinestate : public QObject
      {
          Q_OBJECT
      public:
          explicit machinestate(QObject *parent = nullptr);
      
      
      signals:
      
      public slots:
          void onStateChanged(QOpcUaClient::ClientState state);
      
      private:
          QScopedPointer<QOpcUaClient> m_client;
          QScopedPointer<QOpcUaNode> m_statusNode;
      };
      
      #endif // MACHINESTATE_H
      
      
      #include "machinestate.h"
      #include <QDebug>
      #include <QUrl>
      
      machinestate::machinestate(QObject *parent) : QObject(parent)
      {
      
          QOpcUaProvider provider;
          qDebug() << provider.availableBackends();
      
          m_client.reset(provider.createClient("open62541"));
          qDebug() << m_client.data();
      
          connect(m_client.data(), &QOpcUaClient::stateChanged, this, &machinestate::onStateChanged);
      
          m_client->connectToEndpoint(QUrl("opc.tcp://localhost:4840"));
      
      }
      
      void machinestate::onStateChanged(QOpcUaClient::ClientState state)
      {
          qDebug() << state;
      }
      
      
      

      I'm using Qt5.13.0.

      Thanks in advance,
      Kind regards.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @TMJJ001 said in QTOpcUa -- connectToEndPoint Error:

      error: no viable conversion from 'QUrl' to 'const QOpcUaEndpointDescription'

      The error tells you what is wrong: QUrl cannot be implicitly converted to QOpcUaEndpointDescription.
      https://doc-snapshots.qt.io/qtopcua/qopcuaclient.html#connectToEndpoint takes a QOpcUaEndpointDescription not QUrl.
      Create a QOpcUaEndpointDescription and pass it to connectToEndpoint.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2
      • T Offline
        T Offline
        thisisseven
        wrote on last edited by
        #3

        Do not use QUrl.
        m_client->connectToEndpoint("opc.tcp://localhost:4840");

        ODБOïO 1 Reply Last reply
        0
        • T thisisseven

          Do not use QUrl.
          m_client->connectToEndpoint("opc.tcp://localhost:4840");

          ODБOïO Offline
          ODБOïO Offline
          ODБOï
          wrote on last edited by
          #4

          @thisisseven it will fail also! As @jsulm said QOpcUaClient::connectToEndpoint takes a QOpcUaEndpointDescription

          T 1 Reply Last reply
          0
          • ODБOïO ODБOï

            @thisisseven it will fail also! As @jsulm said QOpcUaClient::connectToEndpoint takes a QOpcUaEndpointDescription

            T Offline
            T Offline
            thisisseven
            wrote on last edited by thisisseven
            #5

            @LeLev

            QOpcUaProvider *provider=new QOpcUaProvider(this);
            m_client = provider->createClient("open62541");
            if(!m_client){
            qDebug()<<"error";
            }
            m_client->connectToEndpoint("opc.tcp://localhost:4840");

            Check out the article below.
            https://doc-snapshots.qt.io/qtopcua/qtopcua-opcuaviewer-example.html

            ODБOïO 1 Reply Last reply
            0
            • T thisisseven

              @LeLev

              QOpcUaProvider *provider=new QOpcUaProvider(this);
              m_client = provider->createClient("open62541");
              if(!m_client){
              qDebug()<<"error";
              }
              m_client->connectToEndpoint("opc.tcp://localhost:4840");

              Check out the article below.
              https://doc-snapshots.qt.io/qtopcua/qtopcua-opcuaviewer-example.html

              ODБOïO Offline
              ODБOïO Offline
              ODБOï
              wrote on last edited by ODБOï
              #6

              @thisisseven said in QTOpcUa -- connectToEndPoint Error:

              "opc.tcp://localhost:4840"

              76327cf3-2042-4ff5-9db4-a6900ceed2b5-image.png

              https://doc-snapshots.qt.io/qtopcua/qopcuaclient.html#connectToEndpoint
              https://doc-snapshots.qt.io/qtopcua/qopcuaclient.html#usage

              1 Reply Last reply
              0

              • Login

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