Insert a new key into the key map and associate it with a
        macro.

        If the key sequence is already associated with a macro then it
        will be overwritten.

        |Args|

        * ``keysequence`` (**QtmacsKeysequence**): associate a macro with
          a key sequence in this key map.
        * ``macroName`` (**str**): macro name.

        |Returns|

        **None**

        |Raises|

        * **QtmacsArgumentError** if at least one argument has an invalid type.

def qteInsertKey(self, keysequence: QtmacsKeysequence, macroName: str):
        """
        Insert a new key into the key map and associate it with a
        macro.

        If the key sequence is already associated with a macro then it
        will be overwritten.

        |Args|

        * ``keysequence`` (**QtmacsKeysequence**): associate a macro with
          a key sequence in this key map.
        * ``macroName`` (**str**): macro name.

        |Returns|

        **None**

        |Raises|

        * **QtmacsArgumentError** if at least one argument has an invalid type.
        """
        # Get a dedicated reference to self to facilitate traversing
        # through the key map.
        keyMap = self

        # Get the key sequence as a list of tuples, where each tuple
        # contains the the control modifier and the key code, and both
        # are specified as Qt constants.
        keysequence = keysequence.toQtKeylist()

        # Traverse the shortcut sequence and generate new keys as
        # necessary.
        for key in keysequence[:-1]:
            # If the key does not yet exist add an empty dictionary
            # (it will be filled later).
            if key not in keyMap:
                keyMap[key] = {}

            # Similarly, if the key does exist but references anything
            # other than a dictionary (eg. a previously installed
            # ``QtmacdMacro`` instance), then delete it.
            if not isinstance(keyMap[key], dict):
                keyMap[key] = {}

            # Go one level down in the key-map tree.
            keyMap = keyMap[key]

        # Assign the new macro object associated with this key.
        keyMap[keysequence[-1]] = macroName