{"action":"created","issue":{"url":"https://api.github.com/repos/mottosso/Qt.py/issues/65","repository_url":"https://api.github.com/repos/mottosso/Qt.py","labels_url":"https://api.github.com/repos/mottosso/Qt.py/issues/65/labels{/name}","comments_url":"https://api.github.com/repos/mottosso/Qt.py/issues/65/comments","events_url":"https://api.github.com/repos/mottosso/Qt.py/issues/65/events","html_url":"https://github.com/mottosso/Qt.py/issues/65","id":160109906,"number":65,"title":"List of PyQt4 vs PySide incompatibilities","user":{"login":"justinfx","id":282566,"avatar_url":"https://avatars.githubusercontent.com/u/282566?v=3","gravatar_id":"","url":"https://api.github.com/users/justinfx","html_url":"https://github.com/justinfx","followers_url":"https://api.github.com/users/justinfx/followers","following_url":"https://api.github.com/users/justinfx/following{/other_user}","gists_url":"https://api.github.com/users/justinfx/gists{/gist_id}","starred_url":"https://api.github.com/users/justinfx/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinfx/subscriptions","organizations_url":"https://api.github.com/users/justinfx/orgs","repos_url":"https://api.github.com/users/justinfx/repos","events_url":"https://api.github.com/users/justinfx/events{/privacy}","received_events_url":"https://api.github.com/users/justinfx/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-06-14T06:55:41Z","updated_at":"2016-06-19T13:42:19Z","closed_at":null,"body":"I have a very large PySide application that has been developed for over 3 years. I've just started to convert it from PySide to PyQt4 and am using Qt.py to see how well it handles it. Surprisingly, I am hitting quite a decent size list of incompatibilities, so I thought I would list them here. \r\n\r\nThis list it not yet complete, asI have not finished fully testing every area of the app. I am a bit scared though, as Python is dynamic, that I could easily hit more of these during runtime if I don't manage to exercise every branch of the GUI code \r\n\r\n---\r\n\r\nQtCore.Slot - PySide allows for a `result=None` keyword param to set the return type. PyQt4 crashes\r\n\r\n```\r\n    QtCore.Slot(QtGui.QWidget, result=None)\r\nTypeError: string or ASCII unicode expected not 'NoneType'\r\n```\r\n\r\n---\r\n\r\nQAction.triggered signal requires a bool arg in PyQt4, while PySide cannot accept any arguments\r\n\r\n```python\r\n# PySide\r\n>>> a.triggered.emit()\r\n>>> a.triggered.emit(True)\r\nTypeError: triggered() only accept 0 arguments, 2 given!\r\n\r\n# PyQt4\r\n>>> a.triggered.emit()\r\nTypeError: triggered(bool) has 1 argument(s) but 0 provided\r\n\r\n>>> a.triggered.emit(True)  # is checked\r\n```\r\n\r\n---\r\n\r\nQAbstractModel.createIndex(row, col, quint32)\r\n\r\nIn PySide, somehow the last argument (the id) is allowed to be negative and is maintained. While in PyQt4 it gets coerced into an undefined unsigned value.\r\n\r\n```python\r\n\r\n# PySide\r\n>>> idx = model.createIndex(0, 0, -1)\r\n>>> print idx.internalId()\r\n# -1\r\n\r\n# PyQt4\r\n>>> idx = model.createIndex(0, 0, -1)\r\n>>> print idx.internalId()\r\n# 18446744073709551615\r\n```\r\n\r\n* Note - I had been using the id as an index into a list. But the unexpected return value from PyQt4 broke it by being invalid. The workaround was to always check that the returned id was between 0 and the max size I expect.\r\n\r\n---\r\n\r\n```python\r\n# PySide\r\n>>> QtGui.QItemSelection.empty()\r\n\r\n# PyQt4\r\n>>> QtGui.QItemSelection.isEmpty()\r\n```\r\n\r\nHowever, they both do support the len(selection) operation\r\n\r\n---\r\n\r\nClosures\r\n\r\n```python \r\n# valid in PySide\r\ndef someMethod(self):\r\n    def _wrapper():\r\n        self.runSomething(\"foo\")\r\n\r\n    someObject._callback = _wrapper\r\n    someObject.someSignal.connect(_wrapper)\r\n\r\n# In PyQt4 an exception is generated when the signal fires\r\n    def _wrapper():\r\n        self.runSomething(\"foo\")\r\nNameError: free variable 'self' referenced before assignment in enclosing scope\r\n```\r\n\r\n---\r\n\r\nIn PySide, the constructor for `QtGui.QRegExpValidator()` can just take a `QRegExp` instance, and that is all.\r\n\r\nIn PyQt4 you are required to pass some form of a parent argument, otherwise you get a TypeError:\r\n\r\n`QtGui.QRegExpValidator(regex, None)`\r\n```"},"comment":{"url":"https://api.github.com/repos/mottosso/Qt.py/issues/comments/226997989","html_url":"https://github.com/mottosso/Qt.py/issues/65#issuecomment-226997989","issue_url":"https://api.github.com/repos/mottosso/Qt.py/issues/65","id":226997989,"user":{"login":"fredrikaverpil","id":994357,"avatar_url":"https://avatars.githubusercontent.com/u/994357?v=3","gravatar_id":"","url":"https://api.github.com/users/fredrikaverpil","html_url":"https://github.com/fredrikaverpil","followers_url":"https://api.github.com/users/fredrikaverpil/followers","following_url":"https://api.github.com/users/fredrikaverpil/following{/other_user}","gists_url":"https://api.github.com/users/fredrikaverpil/gists{/gist_id}","starred_url":"https://api.github.com/users/fredrikaverpil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fredrikaverpil/subscriptions","organizations_url":"https://api.github.com/users/fredrikaverpil/orgs","repos_url":"https://api.github.com/users/fredrikaverpil/repos","events_url":"https://api.github.com/users/fredrikaverpil/events{/privacy}","received_events_url":"https://api.github.com/users/fredrikaverpil/received_events","type":"User","site_admin":false},"created_at":"2016-06-19T13:42:19Z","updated_at":"2016-06-19T13:42:19Z","body":"> pull request potential\r\n\r\nThat makes a whole lot of sense.\r\n\r\n> If not in the README.md, then how about a separate GOTCHAS.md or something like it?\r\n\r\nAh, that's a really good idea. I like that!\r\nI'm can't come up with a really good name for it ... perhaps we could call it COMPATIBILITY.md or DISCREPANCIES.md. Hm...\r\n\r\n> I'm also cautious not to split information into too many places. I'd rather have a huge README that contains all you need to know.\r\n\r\nI agree in general with you, but I think in this case that the GOTCHAS could become quite huge. Therefore I would like to cast my vote to put this in a separate file and prominently link it from the README."}}
{"actor":{"display_login":"fredrikaverpil"}}