I'm having an issue where I have these "Pie Slices" and each one needs to be selectable BUT due to the nature of Qt it seems each on can only have a bounding rectangle. I'd need some kind of triangle. Using a rectangle would mean that each slice's rectangle would overlap with the other slices rectangles or each rectangle would have to be undersized to fit in the slice which would leave a lot of other empty space in the slice.
Any ideas?
Here's the class I created to generate the Slices if it helps:
class Link_Point(QGraphicsItem):
""" Connection points for object link """
RECT = Component_Point.RECT.adjusted(BORDER_WIDTH/2, BORDER_WIDTH/2, -BORDER_WIDTH/2, -BORDER_WIDTH/2)
def __init__(self, type, parent=None):
super(Link_Point, self).__init__(parent)
# Vars
self.type = type
self.start_angle= 0
self.span = 0
# Settings
self.setFlags( QGraphicsItem.ItemIsSelectable |
QGraphicsItem.ItemIsMovable | # ********* remove this line
QGraphicsItem.ItemIsFocusable )
def Set_Span(self, start_angle, span):
self.start_angle= start_angle
self.span = span
self.update()
def boundingRect(self):
# *** set bounding rect propperly
return Component_Point.RECT
def paint(self, painter, option, widget):
# Draw Pie Slice
pen = QPen()
pen.setStyle(Qt.NoPen)
painter.setPen(pen)
brush = QBrush(LINKCOLOR_DIC[self.type])
painter.setBrush(brush)
painter.drawPie(Link_Point.RECT, self.start_angle, self.span)