QwtPlot embedded in QGraphicsItem (problem with QwtPlotPicker)
Hello everyone,
I have embedded a QwtPlot canvas in a QGraphicsItem using QGraphicsProxyWidget as a child of my QGraphicsItem.
Everything is ok but a strange behavior of the QwtPlotPicker object I have added to be able to select part of the data displayed.
My picker is associated with a QwtPickerDragRectMachine, it has a RectRubberdand and is always on.
When the mouse is pressed the Rubber band is displayed but.. it never ends.
Other mouse clicks don't end the selection, so the select() signal is never emited.
Debugging the code I found that the widgetMouseReleaseEvent() is never called. widgetMousePressEvent() is called everytime the mouse is pressed.
So, I guess that's why my rect selection is never ending.
Any Ideas?
I've checked that mouse events come to my QGraphicsItem successfully.
I reimplemented a picker of my own, to define my own Text Tracker.
Code:
{
public:
protected:
};
Re: QwtPlot embedded in QGraphicsItem (problem with QwtPlotPicker)
QGraphicsProxyWidget is not a widget better don't use this when you can avoid it. Using the graphics view framework for widgets doesn't make much sense beside you really have to deal with graphic primitives ( if it is about having some scroll bars only it doesn't qualify as a good reason ).
But if you really have to do this you have to take care that the QGV framework doesn't swallow any events.
Uwe
Re: QwtPlot embedded in QGraphicsItem (problem with QwtPlotPicker)
Thanks for the tip.
I have an application which display signals using the Graphics/View Framework.
All my item inherits from QGraphicsPolygonItem or QGraphicsRectItem.
I wanted to add a Time/Frequency representation of some signals into another graphicsItem.
So I used a QGraphicsRectItem, and add a widget in it to plot that representation (a QwtPlot with a QwtSpectrogram attached to it).
I found that the only way to do that is by using QGraphicsProxyWidget.
It seems that mouse press and mouse release events are coming succesfully to my QGraphicsProxyWidget's child as I reimplemented a derived class to check that.
Normally, events come from view, by the scene, by the graphics widget if any, and then to QgraphicsItem and its children.
So the QwtPlotPicker receives mousePress but no mouseRelease events. Somewhere between QGraphicsProxyWidget and QwtPlotPicker the event is consumed and not transmitted, but where :
QwtPlot, QwtSpectogram ?
My GraphicsItem also accept hover events, could this be the cause of my issue?
Regards
Re: QwtPlot embedded in QGraphicsItem (problem with QwtPlotPicker)
Quote:
Originally Posted by
Bru
Somewhere between QGraphicsProxyWidget and QwtPlotPicker the event is consumed and not transmitted, but where :
QwtPlot, QwtSpectogram ?
The QGraphicsView framework is to blame.
Uwe