Hi,

This is related to PyQt and I am kind of beginner here.

To show a that particular QGraphicsItem is selected you have to set a property:
Qt Code:
  1. self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable)
To copy to clipboard, switch view to plain text mode 

and in "paint" event, you can draw something to show that item has been selected.
Qt Code:
  1. def paint(self, painter, option, widget):
  2. if option.state and QtGui.QStyle.State_Selected:
  3. painter.setPen(QtCore.Qt.green)
To copy to clipboard, switch view to plain text mode 

It looks pretty easy but it is not working as it has to. To confirm that I did some changes in the example graphicsview>elasticnodes.pyw that comes with PyQt and eventually I encountered the same problem there also.

First change is to add property:
Qt Code:
  1. self.setFlag(QtGui.QGraphicsItem.ItemIsSelectable)
To copy to clipboard, switch view to plain text mode 

and second change is to draw something is paint event:
Qt Code:
  1. if option.state and QtGui.QStyle.State_Selected:
  2. painter.setPen(QtCore.Qt.green)
  3. painter.setBrush(QtCore.Qt.NoBrush)
  4. painter.drawRect(0,0, 10, 10)
To copy to clipboard, switch view to plain text mode 

and resulting image is:


As you can see there are small green color rectangles on every node.

Is it a bug? Is there any property of QGraphicsView that needs to be set/unset to resolve this problem?

Cheers

Prashant

Python 2.5.2
PyQt-Py2.5-gpl-4.4.3-1
Win XP, 32 Bit