QCustomPlot Discussion and Comments

iSelectAxis Signal Not EmittingReturn to overview
September 13, 2017, 23:22
by bob

Hello, I'm confused about why the axisclick signal and slot isn't working within my code. Currently, I'm embedding my customplot (with multiple axis rectangles / plots) within a scroll area. If I click on an axis label, an axis, or axis ticks, I see it being selected/highlighted, however, I don't see the signal/slot connecting to a function which is just a print statement. I am able to connect the signals and slots of other mouse event fine, but I don't know why it doesn't for axisClick. Any ideas?

 customPlot->setInteraction(QCP::iSelectAxes, true);
 connect(customPlot, SIGNAL(axisClick(QCPAxis*,QCPAxis::SelectablePart,QMouseEvent*)), this, SLOT(changeYScale(QCPAxis*,QCPAxis::SelectablePart)));
 connect(customPlot, SIGNAL(mouseWheel(QWheelEvent*)), this, SLOT(mouseWheel(QWheelEvent*)));
 connect(customPlot, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, SLOT(mouseDoubleClickEvent(QMouseEvent*)));
 connect(customPlot, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMoveEvent(QMouseEvent*)));

Note my customPlot is implemented as a subclass of QCustomPlot (for the time being nothing special yet).

class myQCustomPlot : public QCustomPlot
{
 Q_OBJECT
public:
 explicit myQCustomPlot(QWidget *parent = 0);
 ~myQCustomPlot();
protected:
 void mouseWheelEvent(QWheelEvent *mouse_event);
 void mousePressEvent(QMouseEvent *event);
signals:
 void sendMouseMovement(int&);
 void sendDropEvent(QDropEvent* event);
};

August 7, 2024, 05:43
by Phil Marsh

I'm wondering how to get the axis to be selected via mouseclick. I tried:
Plotrect_Actions::Plotrect_Actions(const QVector<PlotDataRect> &plotdatasets, QWidget *parent):plotdatasets(plotdatasets)
{
setupUi(this);
//setAttribute(Qt::WA_DeleteOnClose);
plot=new QCustomPlot(this);
assert(plot);
//plot ->setInteractions(QCP ::iRangeDrag | QCP ::iRangeZoom | QCP ::iSelectAxes);
plot ->setInteraction(QCP ::iSelectAxes, true);
plot ->xAxis ->setSelectableParts(QCPAxis ::spAxis);
plot ->yAxis ->setSelectableParts(QCPAxis ::spAxis);
plot ->yAxis2 ->setSelectableParts(QCPAxis ::spAxis);
....
and still, when I see the resulting plot, I cannot get the clicked on axis to highlight.
Any ideas welcome and thanks,
Phil

AltStyle によって変換されたページ (->オリジナル) /