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. Handling .NET ActiveX event from Qt
Forum Updated to NodeBB v4.3 + New Features

Handling .NET ActiveX event from Qt

Scheduled Pinned Locked Moved General and Desktop
3 Posts 1 Posters 1.6k Views 1 Watching
  • 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.
  • N Offline
    N Offline
    nightroad
    wrote on last edited by
    #1

    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);
    @

    1 Reply Last reply
    0
    • N Offline
      N Offline
      nightroad
      wrote on last edited by
      #2

      Anyone ?

      1 Reply Last reply
      0
      • N Offline
        N Offline
        nightroad
        wrote on last edited by
        #3

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

        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