Results 1 to 4 of 4

Thread: QwtPlot embedded in QGraphicsItem (problem with QwtPlotPicker)

  1. #1
    Join Date
    Feb 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default 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.

    Qt Code:
    1. class TFPicker : public QwtPlotPicker
    2. {
    3. public:
    4. TFPicker(QwtPlotCanvas *canvas) : QwtPlotPicker(canvas) {}
    5. QwtText trackerText(const QPoint &pos) const;
    6. protected:
    7. void widgetMouseReleaseEvent(QMouseEvent *e);
    8. void widgetMousePressEvent(QMouseEvent *e);
    9. };
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default 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

  3. #3
    Join Date
    Feb 2009
    Posts
    2
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default 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

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QwtPlot embedded in QGraphicsItem (problem with QwtPlotPicker)

    Quote Originally Posted by Bru View Post
    Somewhere between QGraphicsProxyWidget and QwtPlotPicker the event is consumed and not transmitted, but where :
    QwtPlot, QwtSpectogram ?
    The QGraphicsView framework is to blame.

    Uwe

Similar Threads

  1. QwtPlot + UI problem
    By petromp in forum Qwt
    Replies: 3
    Last Post: 5th April 2012, 21:35
  2. Replies: 3
    Last Post: 5th January 2011, 07:54
  3. Replies: 14
    Last Post: 20th April 2010, 11:40
  4. QWTPLOT problem
    By umulingu in forum Qwt
    Replies: 5
    Last Post: 25th August 2009, 16:34
  5. Problem with QwtPlot
    By sudheer168 in forum Qwt
    Replies: 1
    Last Post: 11th September 2008, 09:04

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.