[PyQt] Cannot connect to the clicked signal of a QPieSeries
Tony Arnold
tony.arnold at manchester.ac.uk
Wed Mar 21 14:05:04 GMT 2018
Joseba,
On Wed, 2018-03-21 at 12:45 +0100, Joseba Echevarria GarcĂa wrote:
>
I'm trying to create a dynamic QChart plot based on QPieSeries. In
> this context I want to be able to detect which pie slice was
> clicked.and to do so I have set up a basic example (shown below).
>
> My problem is that I am unable to detect which slice was clicked;
> when connecting the `clicked` signal of a Series I get a TypeError
> exception stating:
> TypeError: C++ type 'QPieSlice*' is not supported as a signal
> argument type
>
> I'm guessing the feature is not yet implemented? I have
> unsuccessfully tried to connect each slice's `clicked` signal to the
> slot, but I'm always getting the latest value in the series (
> slice_clicked always sees i=1 always in the example below).
>
> I'm getting the same exception when trying to connect the hovered
> signal. I have also tried passing the type name as a string by using
> the @pyqtSlot decorator, to no success.
>
> Is there anything I can do to be able to connect the `clicked` signal
> for the QPieSeries?
>
> I'm using Python 3.6.3 as bundled with Anaconda, Qt5.10.0, PyQt 5.10
> and PyQtChart 5.10 as downloaded from pip on Windows 7 64 bits.
>
> Sample code:
> import sys
> from PyQt5 import QtWidgets, QtChart, QtGui
I would add a PyQtSlot decorator for this signal and specify the
argument type, viz.,
from PyQt5.QtChart import QPieSlice
@pyqtSlot(QPieSlice)
def slice_clicked(slice):
print('Slice clicked!')
print(slice.pieSize)
Hope this helps.
Regards,
Tony.
--
Tony Arnold MBCS, CITP | Senior IT Security Analyst | Directorate of IT Services | G64, Kilburn Building | The University of Manchester | Manchester M13 9PL | T: +44 161 275 6093 | M: +44 773 330 0039
More information about the PyQt
mailing list