QCustomPlot Discussion and Comments

mouse click event does not workReturn to overview

mouse click event does no

[code]
[/code]twork
Line as cursor on mouse over + values of all graphs is exactly what i would like on my chart.I have adapted the example of erniberry in my programm. Now it is compiling without problems. But no reaction on mouse move, mouse press mouse click.
Here is the connect.
void MainWindow::setupWidgets()
{
  // set menu and button icons
.........
 //   connect(m_ui->logplot, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, SLOT(showCursor(QMouseEvent*)));

  connect(m_ui->logplot, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(showVals(QMouseEvent*)));
  connect(m_ui->logplot, SIGNAL(plottableClick(QCPAbstractPlottable*,int,QMouseEvent*)), this, SLOT(findPoint(QCPAbstractPlottable*,int)));}

and here the event
 void MainWindow::showVals(QMouseEvent *event)
{
 QCPItemLine *cursor = new QCPItemLine(m_ui->logplot);

    //for my "cursor"########
    double mouseX = m_ui->logplot->xAxis->pixelToCoord(event->pos().x());
    double startPos = m_ui->logplot->yAxis->pixelToCoord(0);
    double endPos =m_ui->logplot->yAxis->pixelToCoord(100);
    cursor->start->setCoords(mouseX, startPos);
    cursor->end->setCoords(mouseX, endPos);

    //for the  graph values #####
    for(int i=0; i<m_ui->logplot->graphCount(); ++i)
    {
        int index = m_ui->logplot->graph(i)->findBegin(mouseX);
        double x = m_ui->logplot->graph(i)->dataMainKey(index);
        double y = m_ui->logplot->graph(i)->dataMainValue(index);

        if(mouseX >= 0 && mouseX <= (m_ui->logplot->graph(i)->dataMainKey(m_ui->logplot->graph(i)->dataCount() - 1) + 1))
        {
            qDebug() << index << "X:" << x << "Y:" << y;
        }
        else
        {
            qDebug() << index << "X:" << 0 << "Y:" << 0;
        }
    }
    m_ui->logplot->replot();
}

The signals are emitted correctly, so I can only assume there's an issue with your showVals method. Have you tested whether showVals is called at all, and stepped through it?

hi manu,
no when I debug, nothing happens when I click,doubleclick or press mouse button.I have included <QMouseEvent> and in mainwindow.h in public slots the void showCursor(QMouseEvent *event);I do not know where to activate the mouse event.
Is it possible that: m_ui->logplot->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom );
is in conflic twith mouse event. But I deactivated this line already once.

hi manu,
i searched much more and now I have put the connect command within
void MainWindow::setupWidgets()
{connect(m_ui->logplot, SIGNAL(mouseDoubleClick(QMouseEvent*)), this, SLOT(showVals(QMouseEvent*)));
}
and this is the first time the cursor is shown.But no values up to now.I will continue my search.

I have token other example here in the forum .Now it works fine.Thank you manu!