我正在尝试了解QcustomPlot图层的工作原理。
我想在网格上绘制一个像素图,然后在其上方绘制交叉点。
这是我的代码:
QString file_name;
QImage image;
ui->grid->addLayer("layer1", "main"); //above "main"
ui->grid->setCurrentLayer("layer1");
QPixmap pixels = QPixmap::fromImage(blah blah);
_pixmap->setVisible(true); //_pixmap its a member field
_pixmap->setScaled(true);
_pixmap->setPixmap(pixels);
double left_x = getLeftX();
double right_x = getRightX();
double top_y = getTopY();
double bottom_y = getBottomY();
_pixmap->topLeft->setCoords(left_x, bottom_y);
_pixmap->bottomRight->setCoords(right_x, top_y);
ui->grid->layer("layer1")->replot();
ui->grid->addLayer("layer2", "layer1"); // above "layer1"
ui->grid->setCurrentLayer("layer2");
QVector<double> x;
QVector<double> y;
x.push_back(3);
y.push_back(2);
ui->grid->graph(0)->setData(x,y);
ui->grid->layer("layer2")->replot();
仅绘制像素图,如果我在注释上放置像素图replot,则仅绘制point(3,2)。
我错过了什么吗?