Important: Please read the Qt Code of Conduct -

Call .NET C# dll from QT ?

  • Hi ,
    I'm new in C++ and QT and I need some help.
    I have built a com object (not something visual) with some methods and the task is to call my .NET C# dll from inside QT (a console application or even a Windows Application).
    I read the documentation and tried unsuccessfully to make that call happen.

    I read the below

    but without success.

    Can anyone has a small snippet of code on how to do this in QT ?
    Is QT supports that ?

    I tried to use this
    QAxObject object("C:/Myfolder/MyCOM.dll")
    but I got an unresolved something
    I tried this
    QLibrary lib( "C:\Myfolder\MyCOM.dll" );
    but it was not loaded.
    I ran out of ideas .

    Appreciate any help you could give me.
    thank you in advance

  • I have tried this
    QLibrary mylib("C:\Myfolder\MyCOM.dll");
    bool okLoad = mylib.load();
    bool loaded = mylib.isLoaded();

    and both bool return true
    So, that means that the dll is loaded ?
    And Now how can I call a method from the Com Object ?

  • You need to resolve the functions you would like to call in the dll. The "QLibrary documentation": shows an example.

    Create a typedef for the function prototype, then resolve the function by name.

  • C# DLL cannot directly called like C++ DLL's. So QLibrary cannot be used.

    You can use QAxObject, but your C# DLL need to export COM objects (Interop) which is not enabled by default during compilation.

  • I apologize, you are correct. QLibrary is only for C.

    There is a good example on the QAxBase docs "here":, although I have only used QAxObject to populate Microsoft excel documents

Log in to reply