[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyQt] PyQt5, QGraphicsObject, Selection Indicator, and Multiple Inheritance
From:       Alan Ezust <alan.ezust () gmail ! com>
Date:       2015-02-27 16:30:40
Message-ID: CALy5K9ocw7ZqNp6ue9iqEcP6WB6r9-mH7B_roTe8g+K3c9F5Uw () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


I had a QGraphicsRectItem before that I needed to add signals to.

I had trouble getting multiple inheritance to work between QGraphicsObject
and QGraphicsRectItem. As soon as I tried to call self.setBrush(), the
interpreter crashed, and I am not able to see any kind of error message
that indicates what might be the problem.


class PartFrame2dItem(QGraphicsObject, QGraphicsRectItem):
def __init__(self):

QGraphicsObject.__init__(self)
QGraphicsRectItem.__init__(self)
# A child rectangle item
#self._rect_item = QGraphicsRectItem(self)
#self._rect_item.setZValue(-1)
self.setZValue(-1)
#self._rect_item.setBrush(QBrush(QColor(235,235,235)))
self.setBrush(QBrush(QColor(235,235,235)))

Is there something wrong with my __init__?
Why would it crash like that on the setBrush() ?

So I redesigned it so that the QGraphicsObject creates a child
QGraphicsRectItem. But now, when I select the item from the view, I don't
see any dotted line selection indicator around the thing.

Am I supposed to override and delegate some event handler or method to the
from the QGraphicsObject to the QGraphicsRectItem in order to see that
dotted line selection effect?

Thanks for any insights you might have.

[Attachment #5 (text/html)]

<div dir="ltr"><div><div><div><div>I had a QGraphicsRectItem before that I needed to \
add signals to.<br></div><br></div>I had trouble getting multiple inheritance to work \
between QGraphicsObject and QGraphicsRectItem. As soon as I tried to call \
self.setBrush(), the interpreter crashed, and I am not able to see any kind of error \
message that indicates what might be the problem.<br><br><pre \
style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:&quot;DejaVu \
Sans Mono&quot;;font-size:12pt"><br><span \
style="color:rgb(0,0,128);font-weight:bold">class \
</span>PartFrame2dItem(QGraphicsObject<span style="color:rgb(204,120,50)">, \
</span>QGraphicsRectItem):<br>def __init__(self):<br></pre><pre \
style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:&quot;DejaVu \
Sans Mono&quot;;font-size:12pt;margin-left:40px">QGraphicsObject.<span \
style="color:rgb(178,0,178)">__init__</span>(<span \
style="color:rgb(148,85,141)">self</span>)<br>QGraphicsRectItem.<span \
style="color:rgb(178,0,178)">__init__</span>(<span \
style="color:rgb(148,85,141)">self</span>)<br><span \
style="color:rgb(128,128,128);font-style:italic"># A child rectangle \
item<br></span><span \
style="color:rgb(128,128,128);font-style:italic">#self._rect_item = \
QGraphicsRectItem(self)<br></span><span \
style="color:rgb(128,128,128);font-style:italic">#self._rect_item.setZValue(-1)<br></span><span \
style="color:rgb(148,85,141)">self</span>.setZValue(-<span \
style="color:rgb(0,0,255)">1</span>)<br><span \
style="color:rgb(128,128,128);font-style:italic">#self._rect_item.setBrush(QBrush(QColor(235,235,235)))<br></span><span \
style="color:rgb(148,85,141)">self</span>.setBrush(QBrush(QColor(<span \
style="color:rgb(0,0,255)">235</span><span \
style="color:rgb(204,120,50)">,</span><span \
style="color:rgb(0,0,255)">235</span><span \
style="color:rgb(204,120,50)">,</span><span \
style="color:rgb(0,0,255)">235</span>)))</pre>Is there something wrong with my \
__init__?<br></div><div>Why would it crash like that on the setBrush() \
?<br></div><div><br>So I redesigned it so that the QGraphicsObject creates a child \
QGraphicsRectItem. But now, when I select the item from the view, I don&#39;t see any \
dotted line selection indicator around the thing. <br><br></div>Am I supposed to \
override and delegate some event handler or method to the from the QGraphicsObject to \
the QGraphicsRectItem in order to see that dotted line selection \
effect?<br><br></div>Thanks for any insights you might have. <br><br><br></div>


[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic