QCustomPlot Discussion and Comments

Set pen of selection?Return to overview

At the moment I select a specific area of a graph like this:

(Example values)
int begin = 10;
int end = 75;

QCPDataRange range;

QCPDataSelection selection;


Everything works fine, but when I select a range with too much values, the performance slows down very much.
When I understood it right, it is because of the QPen-width of the selection.

So is it possible to change this width?

I saw from a previous post:

QPen p(Qt::blue, 0, Qt::SolidLine);

But there isnt a method called "setSelectedPen(QPen)", someone knows, how to do this?


myGraph->selectionDecorator()->setPen (p);

Thanks for beeing so active here @define true false!!

Your solution worked perfect!

Do you know, if it is possible to bring the selected part to the front?
Because when I have more graph in the plotter and select a part from the first graph, it is sometimes hard to see it.

"Initially, QCustomPlot has six layers: "background", "grid", "main", "axes", "legend" and "overlay" (in that order). On top is the "overlay" layer, which only contains the QCustomPlot's selection rect (QCustomPlot::selectionRect)." (с) doc

I think the selected part should always be in the top, if you did not add your own layers.

But the selection rect is the "rubberband" selection box. The selection of graphs is drawn in the same method as the graph itself (QCPGraph::draw) so I expect it to be on the same layer as the graph itself.
that you can move to a higher layer, of course, with setLayer.

Thank you

Thank you, I wrote an article。https://itzhai.cn/xuexijiaocheng/825.html