[PyQt] Issue with PyQt5.6 wheel on OS X with QGraphicsItemGroup addToGroup

Nick a.grinner at gmail.com
Mon Jun 20 18:25:03 BST 2016


I've reproduced this bug also on Windows x64 in PyQt 5.6.  It is related to
subclassed QGraphicsItems who have `itemChange()` implemented.  Here is the
code that reproduces the bug I see and that produces different results in
PyQt5.5.1 and prior (and worked in PyQt4 as well for what it's worth) with
and without itemChange() implemented in the subclass.  Output appears at
the bottom.

from PyQt5.QtWidgets import QGraphicsItem, QGraphicsRectItem,
QGraphicsItemGroup

class MyItemGroup(QGraphicsItemGroup):
    def __init__(self, parent=None):
        super(MyItemGroup, self).__init__(parent)

    def __repr__(self):
        return str(type(self).__name__)

class MyRectItemNOIC(QGraphicsRectItem):
    def __init__(self, parent=None):
        super(MyRectItemNOIC, self).__init__(parent)

    def __repr__(self):
        return str(type(self).__name__)


class MyRectItem(QGraphicsRectItem):
    def __init__(self, parent=None):
        super(MyRectItem, self).__init__(parent)


    def __repr__(self):
        return str(type(self).__name__)

    def itemChange(self, change, value):
        return QGraphicsRectItem.itemChange(self, change, value)

if __name__ == '__main__':
    a = MyRectItem()
    b = MyRectItem(a)
    item_group = MyItemGroup()

    print("parent:", b.parentItem())
    item_group.addToGroup(b)
    print(item_group.childItems(), b.parentItem())

    c = MyRectItemNOIC(a)
    print("\nparent NOIC:", c.parentItem())
    item_group.addToGroup(c)
    print(item_group.childItems(), c.parentItem())


Output:

parent: MyRectItem
[] None

parent NOIC: MyRectItem
[MyRectItemNOIC] MyItemGroup


On Thu, Jun 16, 2016 at 2:25 PM, Nick <a.grinner at gmail.com> wrote:

> I've compared PyQt-gpl-5.5.1-snapshot-13f9ece29d02 code with the PyQt-gpl-5.6
> code and see no difference nor in the Qt 5.3 and 5.6 qgraphicsitem.cpp.
>
> Could this be a sip regression I'm seeing?
>
> In general everything about the 5.6.x builds and execution seems normal in
> my code except this addToGroup issue I see with custom objects.
>
> the problem persists in PyQt-gpl-5.6.1-snapshot as well when I build from
> source.
>
> In summary on OS X:
>
> Python 3.5 with PyQt5.5.1 works
> Python 3.5 with PyQt5.6.1-snapshot fails to addToGroup()
> Python 3.5 with PyQt5.6.0 fails
> Python 3.4 with PyQt5.5.1 works
>
> I can work on a simple case reproduction if that helps as well.
>
> -Nick
>
> On Wed, Jun 15, 2016 at 7:41 PM, Nick <a.grinner at gmail.com> wrote:
>
>> Actually my code works as of a build of
>> PyQt-gpl-5.5.1-snapshot-13f9ece29d02
>>
>> Thanks,
>>
>> -Nick
>>
>> On Wed, Jun 15, 2016 at 7:29 PM, Nick <a.grinner at gmail.com> wrote:
>>
>>> I have working code that I can run in a self built PyQt5.3 build that
>>> ceases to work in the wheel from pypi of PyQt5.6 for OS X.  Specifically
>>> addToGroup() fails.  Did something change in the Qt5.x or PyQt5.x source
>>> from 5.3 to 5.6 related to this that anyone is aware of?
>>>
>>> In 5.6 when I call addToGroup of subclassed QGraphicsItem, the
>>> parentItem of the Item becomes None and therefore calls to
>>> group.childItems() return an empty list, whereas with no code changes in
>>> the 5.3 I built the calls behave as intended.
>>>
>>> I have not yet tested on Windows.
>>>
>>> Thanks,
>>>
>>> -Nick
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20160620/52e9c73f/attachment.html>


More information about the PyQt mailing list