Results 1 to 5 of 5

Thread: Qwt Legend

  1. #1
    Join Date
    Oct 2008
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Arrow Qwt Legend

    hello,

    i was observing the cpu plot example. On executing the binary i noticed that the "user" and the "system" legend items were already checked and the corresponding curves were shown. However i would like only one curve to be shown when the widget starts.

    1. How do i change this default behavior ?
    2. Secondly, when a legend item is clicked..say "total" i would like the previous selection to be unchecked automatically. This does not happen in the example.

    The code looks something like this:

    Qt Code:
    1. connect(this, SIGNAL(legendChecked(QwtPlotItem *, bool)),
    2. SLOT(showCurve(QwtPlotItem *, bool)));
    To copy to clipboard, switch view to plain text mode 

    and

    Qt Code:
    1. void CpuPlot::showCurve(QwtPlotItem *item, bool on)
    2. {
    3. item->setVisible(on);
    4. QWidget *w = legend()->find(item);
    5. if ( w && w->inherits("QwtLegendItem") )
    6. ((QwtLegendItem *)w)->setChecked(on);
    7.  
    8. replot();
    9. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by maxpayne; 14th October 2008 at 13:40.

  2. #2
    Join Date
    Oct 2008
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qwt Legend

    any body??...this is kinda important...

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

    Default Re: Qwt Legend

    Change the implementation of showCurve:

    When on is true iterate over all curves (plot->itemList( QwtPlotItem::Rtti_PlotCurve) and call showCurve(curve, false) for all other curves.

    Uwe

  4. #4
    Join Date
    Oct 2008
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Qwt Legend

    thanks a lot for your reply,i know you must be busy.I followed your advice and:


    Qt Code:
    1. showCurve(data[System].curve,true);
    2. showCurve(data[User].curve, false);
    3. showCurve(data[Total].curve, false);
    4. showCurve(data[Idle].curve, false);
    To copy to clipboard, switch view to plain text mode 

    this should ensure that i get only the system curve at the beginning.Next:


    Qt Code:
    1. void CpuPlot::showCurve(QwtPlotItem *item, bool on)
    2. {
    3. const QwtPlotItemList &list = this->itemList();
    4. for (QwtPlotItemIterator it = list.begin();it!=list.end();++it)
    5. {
    6. QwtPlotItem *item2 = *it;
    7. if (item2->rtti() == QwtPlotItem::Rtti_PlotCurve)
    8. item2->setVisible(false);
    9. }
    10. item->setVisible(on);
    11. QWidget *w = legend()->find(item);
    12. if ( w && w->inherits("QwtLegendItem") )
    13. ((QwtLegendItem *)w)->setChecked(on);
    14.  
    15. replot();
    16. }
    To copy to clipboard, switch view to plain text mode 

    this removes a curve when the legend item is checked and displays the new curve.

    however i don't see the system curve at the start of the application...even though its legend item is checked.

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

    Default Re: Qwt Legend

    Hide the curves only when "on" is true, otherwise a showCurve(..., false) hides all curves.

    Uwe

Similar Threads

  1. problem installing qwt 5.1.1 on linux for ARM
    By raman_31181 in forum Qwt
    Replies: 4
    Last Post: 18th August 2010, 14:51
  2. QWT introduction
    By nitriles in forum Qwt
    Replies: 4
    Last Post: 28th September 2007, 10:48
  3. Qwt 5.0.2
    By Uwe in forum Qt-based Software
    Replies: 1
    Last Post: 20th September 2007, 18:21
  4. How to upgrade Qwt 5.0.1 to Qwt 5.0.2
    By luffy27 in forum Qwt
    Replies: 1
    Last Post: 15th July 2007, 19:55
  5. use interesting QWT Library with QT3.X
    By raphaelf in forum Qwt
    Replies: 2
    Last Post: 23rd January 2006, 11:24

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.