QCustomPlot Discussion and Comments

Narrowing the plotReturn to overview

Hi,
Is it possible to select the range of the graph with the mouse and get points from that range?

Like drawing a selection rectangle and then retrieving the coordinates of the selected area?

This can be implemented easily by reacting to the mouse signals and creating a QCPItemRect accordingly.

Thanks. Now I have a problem with event coordinate. This code create rect but signal from event get not scaled values.

void MainWindow::press(QCPAbstractPlottable* abstractPlottable , QMouseEvent* event)
{
    QCPItemRect* rect = new QCPItemRect(abstractPlottable->parentPlot());
    abstractPlottable->parentPlot()->addItem(rect);
    rect->topLeft->setCoords(0,0);
    rect->bottomRight->setCoords(event->x(), event->y());
}

I'm not sure what you're trying to do, maybe you can elaborate a bit.

Qt's mouse events always give pixel coordinates as pos() or x() and y(). I'm not sure this is what you want, you might need to transform the coordinates with QCPAxis::pixelToCoord, on the respective axes (e.g. xAxis for the horizontal and yAxis for the vertical dimension.)