Important: Please read the Qt Code of Conduct -

Handling .NET ActiveX event from Qt

  • Hey there,

    I'm trying to use an activex/com object which is written with .NET 4.0 in my qt project, but I've never achieved to handle .NET events as qt signals. I've used booth initializing directly com object as QAxObject and usin dumpcpp tool booth of them didn't work. here is the simple testcase

    Also "dumpcpp" tool is created ColorGenerated event as a slot void add_ColorGenerated(mscorlib::_EventHandler* value);

    but i have no idea how can i use that slot for handling that event.
    // Simple .NET ActiveX which is Raising an event when start() called.
    namespace RandomColorGenerator
    [ClassInterface(ClassInterfaceType.None), Guid("5E20404E-43FC-4A16-873A-C79D36B99750"), ProgId("RandomColorGenerator.ColorGenerator")]
    public class ColorGenerator : IColorGenerator
    public event EventHandler ColorGenerated;

        public void start()
            EventHandler handler = ColorGenerated;
            if (handler != null)
                handler(this, EventArgs.Empty);
        public void stop()
        public string color()
            return "#00FF00";


    //Qt Code which is initializing that activeX
    QAxObject object = new QAxObject("RandomColorGenerator.ColorGenerator");
    //Works fine
    //getting error : Object::connect: No such signal QAxObject::ColorGenerated(IDispatch
    QObject::connect(object, SIGNAL(ColorGenerated(IDispatch*)), this, SLOT(onColorGenerated(IDispatch*)));

    //dumpcpp tool doc output

    Public Slots:

    bool Equals(QVariant obj);
    int GetHashCode();
    mscorlib::_Type* GetType();
    void add_ColorGenerated(mscorlib::_EventHandler* value);
    QString color();
    void remove_ColorGenerated(mscorlib::_EventHandler* value);
    void start();
    void stop();


    void exception(int code, QString source, QString disc, QString help);
    void propertyChanged(QString name);
    void signal(QString name, int argc, void* argv);

  • Anyone ?

  • Is there any workaround about that ? Can i use void add_ColorGenerated(mscorlib::_EventHandler* value) at least as a callback ?

Log in to reply