import sys

try:
    from PySide6.QtCore import QLibraryInfo, qVersion, Qt, QThread, QMetaObject, Slot
    from PySide6.QtWidgets import QApplication
except ImportError:
    from PySide2.QtCore import QLibraryInfo, qVersion, Qt, QThread, QMetaObject, Slot
    from PySide2.QtWidgets import QApplication


class Thread(QThread):
    def run(self):
        QMetaObject.invokeMethod(
           self, "invoked_from_main_thread", Qt.BlockingQueuedConnection
        )

    @Slot()
    def invoked_from_main_thread(self):
        # We never get here in PySide2 5.14.2.
        print("Inside invoked_from_main_thread.")
        app.quit()


if __name__ == '__main__':
    print('Python {}.{}'.format(sys.version_info[0], sys.version_info[1]))
    print(QLibraryInfo.build())
    app = QApplication([])
    t = Thread()
    t.start()
    app.exec_()
    t.wait()
