How to connect to OpcUa Server using Qt library?



  • Hello All,

    I have a OpcUa Server running on a Codesys PLC. I need to implement a simple app that

    • Connects to the OpcUa server(i.e PLC).

    • Read the Data from the PLC and display it on the screen.

    • write the Data and send it to the server.

    Can any one throw some hints on How can I implement OpcUa client in Qt? Thanks

    In my research I have gone through these results:

    • This compay has implemented OpcUa client in QML. but no s(. ce code :(.

    Thanks a lot :)





  • @kuzulis
    I couldn't find the code. All the urls mentioned in the link are resulted as 404. Do you have any piece of code? Thanks a lot.



  • @kuzulis
    found the code Here. Since it is available from 5.7 I have downloaded from here.

    Now How Can I add the code that I have downloaded from github to my project?

    I tried adding external libraries but It didn't detect. Thanks


  • Lifetime Qt Champion

    Hi,

    To get the code from the repository just clone it using git. All addresses are at the bottom of the page @kuzulis indicated.

    If you want to use the qtopcua module in your project, you have to add QT += opcua to your .pro file but first you have to compile and install the module. For that the usual combo applies: qmake, make, make install



  • @SGaist

    If you want to use the qtopcua module in your project, you have to add QT += opcua to your .pro file

    As you said it has resulted me Unknown module QT:opcua because i didn't compile and install the module.

    but first you have to compile and install the module. For that the usual combo applies: qmake, make, make install.

    I couldn't find the instructions on how to install this module using qmake, make, make install.
    **Could you point me to an example or tutorial? **

    FYI: Since Qtopcua is using freeopcua I think i need to add first freeopuca libraries first. Since freeopcua needs Boost and libxml2 for Windows( seen in README.md). So I need to add Boost and libxml2 to my Qt Creator and add it to my QOPCUAClient Project. Then install the module Qtopcua . Finally Run. Are my steps are correct ? Thank you so much.

    P.S: Sorry for late reply.


  • Lifetime Qt Champion

    The combo described is the list of commands you use to build a Qt module. Since you are on windows, make will be either nmake if you are using Visual Studio or mingw32-make if your MinGW.

    What do you mean by "add to Qt Creator" ? You will need to add the paths to their respective .dlls folder to the PATH environment variable in the Run part of the Project panel so they are found when running your application from Qt Creator.

    There should be no need to add them to your project, everything should be handled by the module itself.

    But no, you should first build and install the module and then build your project.

    On a side note, I wouldn't name a project with something that resembles to a Qt class unless you plan to submit it for inclusion in the module ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.