Skip to content

Conversation

@quornian
Copy link

For example, in this first case we have what looks like a QApplication
object, but it is not really there and will cause problems later.

$ python -c 'from PyQt4 import QtGui; print QtGui.qApp'
<PyQt4.QtGui.QApplication object at 0x7f2f884776b0>

$ python -c 'from PySide import QtGui; print QtGui.qApp'
None

Instead we can use QtGui.QApplication.instance(), which always works and
is documented in PySide to return the same as QtGui.qApp anyway.

quornian and others added 2 commits March 28, 2017 18:19
For example, in this first case we have what looks like a QApplication
object, but it is not really there and will cause problems later.

$ python -c 'from PyQt4 import QtGui; print QtGui.qApp'
<PyQt4.QtGui.QApplication object at 0x7f2f884776b0>

$ python -c 'from PySide import QtGui; print QtGui.qApp'
None

Instead we can use QtGui.QApplication.instance(), which always works and
is documented in PySide to return the same as QtGui.qApp anyway.
@quornian
Copy link
Author

Hi @manneohrstrom. Is there any chance this can be merged?

To add more context, the code added by the two commits ac2ef1b and ca9059d makes use of QGui.qApp, which is not set to None in PyQt4 at startup (it's some uninitialized QApplication struct). In PySide it all works fine. Using QtGui.QApplication.instance() on the other hand, always works.

The problem apparently exists in PyQt5 too (with a much better explanation):
https://stackoverflow.com/a/40405396

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant