Results 1 to 5 of 5

Thread: How plot knows when something has been attached to it?

  1. #1
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Question How plot knows when something has been attached to it?

    Guys,

    I'm creating specialized plot object in which I would like to know when an plot item has been attached to it.

    I've looked around but I can't find a way to do it.

    QwtPlotItem is not an QObject, it doesn't emit any signals.
    When it's attached to a plot i calls QwtPlot::attachItem(), but this function doesn't do much nor I can overload it.

    Any ideas how plot can know when something has been attached to it?

    Cheers!

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: How plot knows when something has been attached to it?

    one way is by iterating QwtPlot::itemList()
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How plot knows when something has been attached to it?

    one way is by iterating QwtPlot::itemList()
    Yes, that will tell you what is there, but as far as I know there is no way to be notified when something new is added. About the only way is if autoreplot is turned on, then adding something new will trigger a replot. That's not very satisfactory.

  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: How plot knows when something has been attached to it?

    Use YourPlot::attach instead of QwtPlotItem::attach():

    Qt Code:
    1. class YourPlot: public QwtPlot
    2. {
    3. public:
    4. ...
    5. void attach( QwtPlotItem *item, bool on )
    6. {
    7. item->attach( this, on );
    8. emit attached( item, on );
    9. }
    10. signals:
    11. void attached( QwtPlotItem *item, bool on );
    12. };
    To copy to clipboard, switch view to plain text mode 

    Having such a notification makes sense and I will add them for Qwt 6.1.

    Uwe

  5. #5
    Join Date
    Sep 2011
    Location
    Manchester
    Posts
    538
    Thanks
    3
    Thanked 106 Times in 103 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How plot knows when something has been attached to it?

    Thanks for reply guys.

    Uwe: I was thinking about such approach, but then if some regular item will get attached to a plot in usual way - I won't know about it.

    I'll wait for 6.1 then if it can't be done now.

    Thanks again!

Similar Threads

  1. Replies: 4
    Last Post: 27th June 2021, 02:23
  2. getting attached curve to a plot
    By corrado1972 in forum Qwt
    Replies: 2
    Last Post: 22nd June 2011, 09:35
  3. Replies: 9
    Last Post: 14th January 2011, 09:54
  4. Replies: 2
    Last Post: 26th March 2009, 08:43
  5. Replies: 7
    Last Post: 22nd September 2008, 22:05

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.