QCustomPlot Discussion and Comments

QCPAbstractItem plotting orderingReturn to overview

Hello,

I would like to know if it is possible to control the plotting ordering of QCPAbstractItem's ? My objective is to be able to allow user to put a QCPAbstramItem "above" or "below" other items (or at least "above all" and "below all"). In other words, I would like to control the z-index of the items.

Thanks in advance !

maybe like this

const int NumberItem = 100;
QVector <QCPAbstractItem*> items(NumberItem);
for(int i = 0; i < NumberItem ; i++){
    items[i] = new QCPItemLine(parentPlot);
    parentPlot->addLayer(QString::number(i));
    items[i]->setLayer(QString::number(i));
}
...
//when user click Item
parentPlot->moveLayer(
    parentPlot->layer(QString::number(items.indexOf(ClickedItem)))
    , parentPlot->layer(parentPlot->layerCount() - 1)
);

but I think it's not the best solution

Thanks for your reply !

I have already thought about the idea of using layers but it requires me a difficult algorithm to determine which item shall or not stay on the highest layer (for example, if I have 2 items A and B which overlaps and 2 items C and D which overlaps, if user clicks on item A, I have to detect that B shall go on the lower layer and A on higher layer and C and D shall stay as they).

At the moment there's no way to control the order within a layer, except for moving them all to a different one and then re-adding them to the original layer in the needed order. The layer system is intended to control rendering order, but I agree that it's not so good for your use case.

In the next minor version I'll add a facility to also move layerables within a layer, e.g. a method like

QCPLayerable::setLayerOrder(int index);
QCPLayerable::setLayerOrder(QCPLayerable* other, QCPLayer::LayerInsertMode mode);

Thanks DerManu, that's a good news :-)
Do you know when this minor version will be released ?