is possible when zoom on plot the background image will zoom within plot ?
is possible when zoom on plot the background image will zoom within plot ?
If you want to pin an image to plot coordinates, you should rather use QCPItemPixmap
(and set its topLeft
/bottomRight
positions to ptPlotCoords
, see the item tutorial/demo for how to work with items). Use the layer system to place the pixmap item on a layer below all the other graphs, if you want to retain the "background" effect.
I did what you say like below:
ui->widget->setInteractions(QCP::iRangeDrag | QCP::iRangeZoom); QCPItemPixmap *MyImage = new QCPItemPixmap(ui->widget); MyImage->setPixmap(QPixmap("./Tiger1.jpg")); MyImage->topLeft->setType(QCPItemPosition::ptPlotCoords); MyImage->bottomRight->setType(QCPItemPosition::ptPlotCoords); ui->widget->addLayer("imageLayer"); ui->widget->addItem(MyImage); ui->widget->addLayer("plotLayer"); ui->widget->setCurrentLayer("plotLayer");