Explode Pie Slice when Hover Mouse
I would like to explode each pie slice of a pie chart when hovering the mouse over each slice. I've looked in pie-slice docs and found onHover, but cannot figure out the syntax to get each slice to explode when hovered.
I create the pie slices like this:
Code:
if pie1 > 0:
_slice = series.append('Equity ' + str("{:.0f}%".format(pie1 * 100)), pie1)
_slice.
setBrush(QColor('#FF00FF')) _slice.
setLabelFont(QFont(self.
pieFont))
If it's possible to do this, what would I add to or change the above code?
Re: Explode Pie Slice when Hover Mouse
You need to connect a slot to the QPieSlice::hovered() signal for each slice. In the slot, you call _slice.setExploded( state ) (where "state" is the value passed into the slot from the signal). You can use the same slot for all of the slices, but you would have to use the QObject::sender() method in the slot to retrieve the instance of the pie slice that sent the signal.
BTW, QPieSlice does not have any "onHover" method.