QCustomPlot Discussion and Comments

How can i add a QCutomPlot into a QGraphicsSceneReturn to overview

How can I add a QCutomPlot into a QGraphicsScene without messing up the interactions in QCustomplot?
Because if I click on my QCustomplot I'm able to move my graph but I can not stop it from moving.
Furthermore I can not zoom at all. How can I make my QCustomplot moveable in QGraphicsScene.

Thank you for help in advance

I have same problem. Somehow QCP::iRangeDrag does not work right in a QGraphicsScene.
I hope we will get an Answer why not.

I found that QCustomPlot::mousePressEvent() doesn't appear to every call event->accept() which is required for the QGraphicsProxyWidget() to work properly. If you subclass QCustomPlot() and override mousePressEvent() like below mouse interaction behaves like you'd expect.

void MyQCPlotWidget::mousePressEvent(QMouseEvent *event)

The reason this only seems to affect the drag behavior is because the drag behavior depends on subsequent mouse events to be handled by the widget. Things like wheelEvent work because it's a single event, which does work when you don't accept the event.

I first attempted to fix this in the QCustomPlot source code and it wasn't working (which drove me crazy for a while) but it turns out I was calling event->accept() prior to QWidget::mousePressEvent(event) being called which must override the event's state (just guessing to why this didn't work, I didn't confirm what QWidget does). Doing the subclass ensured that the event was accepted and everything started working. This fix probably should be applied after calling QWidget::mousePressEvent() and should be applied to all the standard events that QCustomPlot handles to ensure it works properly when wrapped by QGraphicsProxyWidget when being placed into a QGraphicsScene. I suspect this would be a minor patch to QCustomPlot to get this working out of the box without the need to subclass.

I still do have some issues with tooltips only appearing for half a second before closing when QCustomPlot is wrapped in a QGraphicsProxyWidget, which may be related. I'm still troubleshooting that behavior.

Hopefully this helps.

Good catch jscurlee, QWidget::mousePressEvent code indeed calls event->ignore() and only for popups calls event->accept().

I'm currently busy with QCP 2 features but I'll make sure this event issue is fixed for 2.0 and 1.3.2.

Looking at the code and the docs I believe I should never be calling the mousePressEvent base class implementation... I will have to see in my git blame what I was thinking...