QCustomPlot Discussion and Comments

Drawing a rectangleReturn to overview

I apologize in advance for my English, I write through Google translate.
Trying to do the scaling rectangle, there was a problem with the rendering of the rectangle.
Do so:

rect = new QCPItemRect(ui->customPlot);
rect ->setVisible(false);
ui->customPlot->addItem(rect );
rect ->setPen(QPen(Qt::black));
rect ->topLeft->setType(QCPItemPosition::ptAxisRectRatio);
rect ->bottomRight->setType(QCPItemPosition::ptAxisRectRatio);

void MainWindow::mousePress(QMouseEvent *event)
{
	p1 = event->pos();
	rubber->setVisible(true);
}

void MainWindow::mouseMove(QMouseEvent *event)
{
	if (rect ->visible()){
		rect ->topLeft->setPixelPoint(p1);
		rect ->bottomRight->setPixelPoint(event->pos());
	}
}

void MainWindow::mouseRelease(QMouseEvent *event)
{
	rect ->setVisible(false);
}

Rectangle is not displayed.
Tell me what I'm doing wrong?

Forgot:

connect(ui->customPlot, SIGNAL(mousePress(QMouseEvent*)), this, SLOT(mousePress(QMouseEvent*)));
	connect(ui->customPlot, SIGNAL(mouseMove(QMouseEvent*)), this, SLOT(mouseMove(QMouseEvent*)));	
	connect(ui->customPlot, SIGNAL(mouseRelease(QMouseEvent*)), this, SLOT(mouseRelease(QMouseEvent*)));

А с областью выделения разобрался уже? Чего с позицией то не так было?
А здесь не пойму где у тебя ui-customPlot->replot(); при отрисовке области выделения

Hello,

Are you able to add this QCPItemRect on QcustomPlot?

I am also trying to add QCPItemRect on QCustomPlot But I am getting error that addItem is not a member of QCustomPlot.

rect = new QCPItemRect(ui->customPlot);
rect ->setVisible(false);
ui->customPlot->addItem(rect ); // Getting error here. I am using 2.0 version

Please let me know if you have done this.

Thanks

according to the docs it is now

bool QCustomPlot::registerItem ( QCPAbstractItem * item)
http://www.qcustomplot.com/documentation/classQCustomPlot.html#afbd4010b2e3f364c8d512691b2a1640a