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

List:       pykde
Subject:    Re: [PyQt] item selection in a graphicsscene
From:       Matteo Boscolo <matteo.boscolo () boscolini ! eu>
Date:       2012-09-16 4:24:24
Message-ID: 50555478.1080105 () boscolini ! eu
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Have a look at

http://pythoncad.git.sourceforge.net/git/gitweb.cgi?p=pythoncad/pythoncad;a=blob;f=Pyt \
honCAD/Interface/cadscene.py;h=77cf54b821f244975372ed2d025c9c7a90033247;hb=refs/heads/R38


regards,
Matteo

Il 14/09/2012 23:28, Martin Airs ha scritto:
> good day all,
> 
> I'm currently writing a Plasmoid for KDE, so I'm not 100% certain who's lap to
> lay this in, but I'll try here first.
> 
> I'm using a Plasma.Frame which inherits a QGraphicsWidget, in my subclass I
> have reimplemented the itemChange function so I can set the element prefix of
> the SVG used to paint the frame.
> 
> when i press each item with the left mouse button, everything works as
> expected :)
> however if i right click an item, its ElementPrefix changes ok and the menu
> pops up, but the other item that is selected doesn't deselect. and i end up
> with 2 selected items until i click one again.
> 
> Martin
> 
> here is a snippet of the code...
> 
> def itemChange(self, change, value):
> if change == QGraphicsItem.ItemSelectedChange:
> print "selection changed"
> if value == QVariant(True):
> self.border.setElementPrefix("selected")
> else:
> self.border.setElementPrefix("normal")
> self.update()
> return value
> 
> def mousePressEvent(self, event):
> if event.button() == 1:
> self.setSelected(1)
> self.update()
> if event.button() == 2:
> self.setSelected(1)
> self.update()
> self.menu.exec_(QCursor.pos())
> 
> 
> _______________________________________________
> PyQt mailing list    PyQt@riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[Attachment #5 (text/html)]

<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Have a look at<br>
      <br>
      <a
href="http://pythoncad.git.sourceforge.net/git/gitweb.cgi?p=pythoncad/pythoncad;a=blob \
;f=PythonCAD/Interface/cadscene.py;h=77cf54b821f244975372ed2d025c9c7a90033247;hb=refs/ \
heads/R38">http://pythoncad.git.sourceforge.net/git/gitweb.cgi?p=pythoncad/pythoncad;a \
=blob;f=PythonCAD/Interface/cadscene.py;h=77cf54b821f244975372ed2d025c9c7a90033247;hb=refs/heads/R38</a><br>
  <br>
      regards,<br>
      Matteo<br>
      <br>
      Il 14/09/2012 23:28, Martin Airs ha scritto:<br>
    </div>
    <blockquote cite="mid:2372281.jZ06a9LIfo@desktop.localdomain"
      type="cite">
      <pre wrap="">good day all,

I'm currently writing a Plasmoid for KDE, so I'm not 100% certain who's lap to 
lay this in, but I'll try here first.

I'm using a Plasma.Frame which inherits a QGraphicsWidget, in my subclass I 
have reimplemented the itemChange function so I can set the element prefix of 
the SVG used to paint the frame.

when i press each item with the left mouse button, everything works as 
expected :)
however if i right click an item, its ElementPrefix changes ok and the menu 
pops up, but the other item that is selected doesn't deselect. and i end up 
with 2 selected items until i click one again.

Martin

here is a snippet of the code...

    def itemChange(self, change, value):
        if change == QGraphicsItem.ItemSelectedChange:
            print "selection changed"
            if value == QVariant(True):
               self.border.setElementPrefix("selected")
            else:
               self.border.setElementPrefix("normal")
            self.update()
        return value

    def mousePressEvent(self, event):
        if event.button() == 1:
            self.setSelected(1)
            self.update()
        if event.button() == 2:
            self.setSelected(1)
            self.update()
            self.menu.exec_(QCursor.pos())</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
PyQt mailing list    <a class="moz-txt-link-abbreviated" \
href="mailto:PyQt@riverbankcomputing.com">PyQt@riverbankcomputing.com</a> <a \
class="moz-txt-link-freetext" \
href="http://www.riverbankcomputing.com/mailman/listinfo/pyqt">http://www.riverbankcomputing.com/mailman/listinfo/pyqt</a></pre>
  </blockquote>
    <br>
  </body>
</html>



_______________________________________________
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