def qteRegisterMacro(self, macroCls, replaceMacro: bool=False,
                         macroName: str=None):
        if not issubclass(macroCls, QtmacsMacro):
            args = ('macroCls', 'class QtmacsMacro', inspect.stack()[0][3])
            raise QtmacsArgumentError(*args)
        try:
            macroObj = macroCls()
        except Exception:
            msg = 'The macro <b>{}</b> has a faulty constructor.'
            msg = msg.format(macroCls.__name__)
            self.qteLogger.error(msg, stack_info=True)
            return None
        if macroName is None:
            if macroObj.qteMacroName() is None:
                macroName = self.qteMacroNameMangling(macroCls)
            else:
                macroName = macroObj.qteMacroName()
        macroObj._qteMacroName = macroName
        if len(macroObj.qteAppletSignature()) == 0:
            msg = 'Macro <b>{}</b> has no applet signatures.'.format(macroName)
            self.qteLogger.error(msg, stack_info=True)
            return None
        if len(macroObj.qteWidgetSignature()) == 0:
            msg = 'Macro <b>{}</b> has no widget signatures.'.format(macroName)
            self.qteLogger.error(msg, stack_info=True)
            return None
        anyRegistered = False
        for app_sig in macroObj.qteAppletSignature():
            for wid_sig in macroObj.qteWidgetSignature():
                macroNameInternal = (macroName, app_sig, wid_sig)
                if macroNameInternal in self._qteRegistryMacros:
                    if replaceMacro:
                        tmp = self._qteRegistryMacros.pop(macroNameInternal)
                        msg = 'Replacing existing macro <b>{}</b> with new {}.'
                        msg = msg.format(macroNameInternal, macroObj)
                        self.qteLogger.info(msg)
                        tmp.deleteLater()
                    else:
                        msg = 'Macro <b>{}</b> already exists (not replaced).'
                        msg = msg.format(macroNameInternal)
                        self.qteLogger.info(msg)
                        continue
                self._qteRegistryMacros[macroNameInternal] = macroObj
                msg = ('Macro <b>{}</b> successfully registered.'
                       .format(macroNameInternal))
                self.qteLogger.info(msg)
                anyRegistered = True
        return macroName