pytest-dev / pytest-qt

pytest plugin for Qt (PyQt5/PyQt6 and PySide2/PySide6) application testing
https://pytest-qt.readthedocs.io
MIT License
409 stars 70 forks source link

Add more info about qApp pointer #505

Closed hakonhagland closed 1 year ago

hakonhagland commented 1 year ago

Add more info in the documentation about how to get the qApp pointer when using the qtbot fixture, see issue #504 for more information.

hakonhagland commented 1 year ago

Add more info in the documentation about how to get the qApp pointer

@nicoddemus Sorry, I did not check the sphinx output. I think there is something wrong with the backticks:

image

I will try to fix it.

hakonhagland commented 1 year ago

The QApplication object is accessible through the QApplication.instance() method

I also discovered that you can use the qapp_cls fixture

https://github.com/pytest-dev/pytest-qt/blob/f1a6ac554c1d2a81392ed526c56c49265b6a02ea/src/pytestqt/plugin.py#L32

to get the object. Maybe we should also mention this alternative in the documentation?

The-Compiler commented 1 year ago

qapp_cls gives you the class (it's intended to be overridden by your own code to customize what to use). qapp will give you the QApplication instance.

hakonhagland commented 1 year ago

qapp will give you the QApplication instance.

@The-Compiler Thanks for the information! I have updated PR #506 such that the docs mentions this qapp fixture instead of QApplication.instance()

nicoddemus commented 1 year ago

@nicoddemus Sorry, I did not check the sphinx output. I think there is something wrong with the backticks:

No worries, I missed that as well. Thanks for the follow up!