I found the answer to my own question elsewhere. In the slot function within the QMainWindow object you would, after defining the QWidget object, write the code:
self.widget.setWindowModality(QtCore.Qt.WindowModality.ApplicationModal)
Applying an integer as a parameter to the self.widget.setWindowmodality(2)
function worked in PyQt5 but is deprecated in PyQt6 and PySide6 therefore should be avoided as both ways work in PyQt5