QCustomPlot Discussion and Comments

Error in click event on an QCPItemText Return to overview

void MainWindow::createText(QCustomPlot *obj,double x1,double y1,string text,int fontHeight,QVector<QCPItemText*> *rectangleVector,bool doSubscribeToClickEvent){
    // add the text label at the top:
    QCPItemText *textLabel = new QCPItemText(obj);
    textLabel->position->setCoords(x1,y1); // place position at center/top of axis rect
    textLabel->setText(QString::fromStdString(text));
    textLabel->setBrush(QBrush(Qt::green));
    textLabel->setFont(QFont(font().family(), fontHeight)); // make font a bit larger
    rectangleVector->push_back(textLabel);

    if(doSubscribeToClickEvent){
    connect(textLabel, SIGNAL(itemClick(QCPAbstractItem *item, QMouseEvent *event)), this, SLOT(itemClicked(QCPAbstractItem *item, QMouseEvent *event)) );
    //Tried this as well
    //connect(textLabel, SIGNAL(itemClick(QCPAbstractItem*, QMouseEvent*)), this, SLOT(itemClicked(QCPAbstractItem*, QMouseEvent*)) );
    }
}

void MainWindow::itemClicked (QCPAbstractItem *item, QMouseEvent *event) {
    cout <<"Text clicked";
}

Getting the error
QObject::connect: No such signal QCPItemText::itemClick() in ../plot/mainwindow.cpp:93
QObject::connect: (receiver name: 'MainWindow')

Any help is appreciated.

See here:
QCustomPlot::itemClick
It's a signal of QCustomPlot, not QCPItemText.

What would the event which would allow me to capture the click on 'QCPItemText ' .I tried using 'mousePressEvent' but it also said the same thing 'No such signal'

mouse press event isnt a signal, it is a slot in qwidget. i dont think that qcpitemtext is even a widget... it probably doesnt even have that function