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 http://pastebin.com/juU9WpcR

    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);
            }
            Console.WriteLine("ColorGenerator::Start");
        }
    
        public void stop()
        {
            Console.WriteLine("ColorGenerator::Stop");
        }
    
        public string color()
        {
            return "#00FF00";
        }
    }
    

    }

    //Qt Code which is initializing that activeX
    QAxObject object = new QAxObject("RandomColorGenerator.ColorGenerator");
    //Works fine
    object->dynamicCall("stop()");
    //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();

    Signals:

    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
 

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