Results 1 to 3 of 3

Thread: where is QMetaObject::slotNames in Qt 4.7

  1. #1
    Join Date
    Dec 2009
    Posts
    65
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android
    Thanks
    10
    Thanked 4 Times in 4 Posts

    Default where is QMetaObject::slotNames in Qt 4.7

    I am collecting general information about class (derived from QObject) and i want to display available properties, signals and slots.
    in Qt 3 there was a method (found it on google)
    Qt Code:
    1. QStrList QMetaObject::slotNames(bool super = FALSE)
    To copy to clipboard, switch view to plain text mode 
    that could collect all slots, even inherited

    in Qt 4.7 iterating trough QMetaObject like in example
    Qt Code:
    1. const QMetaObject* metaObject = obj->metaObject();
    2. QStringList methods;
    3. for(int i = metaObject->methodOffset(); i < metaObject->methodCount(); ++i)
    4. methods << QString::fromLatin1(metaObject->method(i).signature());
    To copy to clipboard, switch view to plain text mode 
    I get all methods bot not inherited ones
    What am i missing?
    Is there a replacement for slotNames in qt 4.7?

  2. #2
    Join Date
    Feb 2011
    Location
    Bangalore
    Posts
    207
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    20
    Thanked 28 Times in 27 Posts

    Default Re: where is QMetaObject::slotNames in Qt 4.7

    In your code you are using QMetaObject:ffset(). What it does is it loops only through the metaobject of the class defined. You can loop from 0 to methodCount() to give you full list. Or you can make a recursive function and call using superclass metaobject by using QMetaObject::superclass() if you need finer control.

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

    davidovv (11th September 2012)

  4. #3
    Join Date
    Dec 2009
    Posts
    65
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android
    Thanks
    10
    Thanked 4 Times in 4 Posts

    Default Re: where is QMetaObject::slotNames in Qt 4.7

    I did create recoursive function to serch superclass, and found all signals, but then i got double information for slots that were reimplemented,
    When i first read (misred) documentation for methodOffset() i didnt realize that when startin from zero i will get all methods from super classes.
    Loop from zero is bether way. Thanks.

Similar Threads

  1. Problems with QMetaObject::invokeMethod
    By AlphaWolf in forum Qt Programming
    Replies: 3
    Last Post: 13th September 2012, 11:57
  2. QMetaObject cast Error
    By nirab_25 in forum Qt Programming
    Replies: 2
    Last Post: 27th October 2010, 08:58
  3. How to use QMetaObject::invokeMethod?
    By niko in forum Qt Programming
    Replies: 3
    Last Post: 26th January 2008, 16:02
  4. reflection and qmetaobject
    By KShots in forum Qt Programming
    Replies: 8
    Last Post: 16th May 2007, 20:53
  5. Reg - QMetaObject Error
    By suresh in forum Newbie
    Replies: 12
    Last Post: 4th September 2006, 22:27

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
  •  
Qt is a trademark of The Qt Company.