Skip to content

No way to get Qt exit code (return value of QApplication.exec) #106

Open
@QQ80

Description

@QQ80

There is currently no way to access the Qt Application's return code, as returned by QApplication.exec. Right now it is saved as rslt in _QEventLoop.run_forever and returned, but this return value is never used, with both qasync.run and QEventLoop.run_until_complete.

Here is a sample app with a button that should cause the app to exit with code 1, but doesn't:

import asyncio
import sys
from PyQt6.QtWidgets import QPushButton
import qasync
from qasync import QApplication


async def main():
    app = QApplication.instance()

    app_quit_event = asyncio.Event()
    app.aboutToQuit.connect(app_quit_event.set)

    exit_btn = QPushButton("Exit")
    exit_btn.clicked.connect(lambda: app.exit(1))
    exit_btn.show()

    await app_quit_event.wait()
    #return app.exitCode??


sys.exit(qasync.run(main())) # qasync.run returns 0

Shouldn't there should be some way to grab the Qt exit code without bookkeeping it in user code?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions