from PySide2.QtCore import QMetaMethod, QMetaObject, QObject, QTimer, Slot

class MyTimer(QTimer):
    def __init__(self):
        super(MyTimer, self).__init__()

    @Slot('double')
    def myMethod(self, d):
        print('Hallo', d)

class MyTimer2(MyTimer):
    def __init__(self):
        super(MyTimer2, self).__init__()

    @Slot('double')
    def myMethod2(self, d):
        print('Hallo2', d)


def dumpMetaObj(metaObj, indent):
    methodOffset = metaObj.methodOffset()
    methodCount = metaObj.methodCount()
    superName = ''
    if metaObj.superClass() is not None:
        superName = '(inherits {})'.format(metaObj.superClass().className())
    print('{}{} {} methodOffset={}, methodCount={}'.format(
          indent, metaObj.className(), superName, methodOffset, methodCount))
    for m in range(0, methodCount):
        sep = '->' if m == methodOffset else '  '
        print('{}{}{}'.format(indent, sep, metaObj.method(m).methodSignature()))
    superClass = metaObj.superClass()
    if superClass:
        dumpMetaObj(superClass, indent + '  ')

myt2 = MyTimer2()
print('\nMetaObject hierarchy of MyTimer2')
dumpMetaObj(myt2.metaObject(), ' ')

myt = MyTimer()
print('\nMetaObject hierarchy of MyTimer')
dumpMetaObj(myt.metaObject(), ' ')

print('\nMetaObject hierarchy of QTimer')
dumpMetaObj(QTimer.staticMetaObject, ' ')

print('\n\nMetaObject hierarchy of Qbject')
dumpMetaObj(QObject.staticMetaObject, ' ')
