QCustomPlot Discussion and Comments

Adding layer affects graph and axis selectionReturn to overview

I am creating a real-time graph, and i have a line acting as a cursor moving along with the mouse. Following the performance recomendation I added this cursor to its own layer on top of the “axes” layer. I also have put a label on this custom layer, showing the graphs y value on the cursor. However, adding this layer impedes the selection of a graph or axis. If I put the layer on top of the “grid” layer I can select the graph or axis with no problems, but the label sometimes is drawn under the axis, wich looks bad.

Is there a way to make my custom item be on a layer above “axes” and still be able to select graph and axis?

i havent really looked into the 2.0 code, but there is probably a setting somewhere that changes whether an object/layer is selectable. i would look into that.

clipping the label to the axis rect using "setClipToAxisRect(true);" solved my problem.

so it din't work after all. It turns out that the order of the layer just makes it really hard to select the graph or axis. It still selects but for some reason it's really hard. I tried changing the selection tolerance with no luck.

and to be clear, it's the axis click event that is having trouble occurring.

Just to wrap up what was happening in case anyone comes across this. I was adding new left axis, but since I never set the layer of the new axis, it defaulted to the main layer. since my vertical cursor is always under the mouse (mouse move signal), (even though you can't see it when the mouse is over the axis, because the cursor is clipped to the axis rect) and the cursor layer was added on top of the main layer, I could never actually click the axis as to trigger the axis click event.

The head's up is to keep track of the layer of items you add.

Not regarding this specific problem, but related, if you add a new axis, its horizontal grid is not created in the "grid" layer, but in the same layer as the new axis.