lazy_learner
23rd May 2013, 00:04
I reimplement the mousePressEvent and use QwtPlot::invTransform to transform the coordinate.But it don't work as I expected.
void plot :: mousePressEvent(QMouseEvent *e)
{
if(e->button() == Qt::LeftButton)
{
QPointF temp = e->posF();
QMessageBox::information(this,tr("information!"),tr("the original x posation is %1 and y posation is %2").arg(temp.x()).arg(temp.y()),QMessageBox::Ok|QMes sageBox::Default,QMessageBox::NoButton,QMessageBox ::NoButton);
//picker->invTransform()
temp.setX(this->invTransform(QwtPlot::xBottom,temp.x()));
temp.setY(this->invTransform(QwtPlot::yLeft,temp.y()));
QMessageBox::information(this,tr("information!"),tr("changed x posation is %1 and y posation is %2").arg(temp.x()).arg(temp.y()),QMessageBox::Ok|QMes sageBox::Default,QMessageBox::NoButton,QMessageBox ::NoButton);
}
}
well , it look just like 90569057
but the real coordinate in the axis is is not x=688.05 and y=553.371
void plot :: mousePressEvent(QMouseEvent *e)
{
if(e->button() == Qt::LeftButton)
{
QPointF temp = e->posF();
QMessageBox::information(this,tr("information!"),tr("the original x posation is %1 and y posation is %2").arg(temp.x()).arg(temp.y()),QMessageBox::Ok|QMes sageBox::Default,QMessageBox::NoButton,QMessageBox ::NoButton);
//picker->invTransform()
temp.setX(this->invTransform(QwtPlot::xBottom,temp.x()));
temp.setY(this->invTransform(QwtPlot::yLeft,temp.y()));
QMessageBox::information(this,tr("information!"),tr("changed x posation is %1 and y posation is %2").arg(temp.x()).arg(temp.y()),QMessageBox::Ok|QMes sageBox::Default,QMessageBox::NoButton,QMessageBox ::NoButton);
}
}
well , it look just like 90569057
but the real coordinate in the axis is is not x=688.05 and y=553.371