Results 1 to 2 of 2

Thread: ActiveQt, setControl method.

  1. #1
    Join Date
    Dec 2010
    Posts
    44
    Thanks
    9
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default ActiveQt, setControl method.

    Hi All,

    I am trying to wrap an activeX object with QAxWidget. The activeX object raises some events like "dataReady()". I am trying to connect these events to some slots in Qt. What I have observed is that if I call the connect method before the setControl then the connect method fails saying there is no such signal. But if I call the connect after the setControl then the connect call is successful.

    Qt Code:
    1. b = connect(m_pAxWidget, SIGNAL(dataReady()), this, SLOT(check()));
    2. setControl( CLASSID );
    To copy to clipboard, switch view to plain text mode 
    The above fails with:
    Object::connect: No such signal QAxBase::CardDataChanged() in MainWidget.cpp:16


    Qt Code:
    1. setControl( CLASSID );
    2. b = connect(m_pAxWidget, SIGNAL(dataReady()), this, SLOT(check()));
    To copy to clipboard, switch view to plain text mode 
    This one is successful.

    Does this mean that Qt is able to add signals and slots at run time? if so can anyone briefly describe the mechanism and let me know of the source code files or any place else where I can read about this.

    If adding signals and slots at run time is possible then:

    Is there a way I can propagate the signals emitted from a member object to the parent object at run time? I mean I don't know what signal the member object will emit but whatever it emits the parent should also emit.
    eg:

    class a
    {
    QAxWidget b;
    }

    Now I don't know what signals b emits but I want a mechanism such that whatever b emits a also should emit.

    I hope I am clear.

    Sky

  2. #2
    Join Date
    Aug 2009
    Posts
    52
    Thanked 10 Times in 10 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: ActiveQt, setControl method.

    The signals and slots mechanism implements using Qt's meta-object System.

    Normally, when you want to add new signals or slots to a class, your add the macro Q_OBJECT to the class, then run moc to generate a moc_xxx.cpp file.

    However, although QAxObject and QAxWidget is QObject's subclass, and new signals and slots added to them. But they donot contain an Q_OBJECT in source code, so you cannot run the program moc to generate meta-object.

    Then, where is the meta-object for QAxObject and QAxWidget?

    Qt Code:
    1. const QMetaObject *QAxBase::metaObject() const {
    2. ...
    3. if (!d->ptr || !d->useMetaObject) {
    4. if (qObject()->isWidgetType())
    5. return &qaxwidget_staticMetaObject;
    6. return &qaxobject_staticMetaObject;
    7. }
    8. MetaObjectGenerator generator((QAxBase*)this, d);
    9. return generator.metaObject(parentObject);
    10. }
    To copy to clipboard, switch view to plain text mode 

    MetaObjectGenerator will load infomation from the type lib of your AcitveX, then it create an QMetaObject which contain the signals.

    If your want to know how it works, you had better read the source code of the ActiveQt module. And of course, it is very complex.

  3. The following user says thank you to dbzhang800 for this useful post:

    sky (14th June 2011)

Similar Threads

  1. Calling a method from a non-member method
    By AndresBarbaRoja in forum Newbie
    Replies: 5
    Last Post: 19th March 2011, 10:38
  2. ActiveQt
    By rayner in forum Qt Programming
    Replies: 1
    Last Post: 9th December 2010, 00:37
  3. Replies: 1
    Last Post: 25th November 2010, 11:37
  4. Replies: 0
    Last Post: 20th December 2009, 15:37
  5. Qt {ActiveQt}
    By QTInfinity in forum Newbie
    Replies: 2
    Last Post: 26th July 2008, 08:56

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.