Results 1 to 3 of 3

Thread: How control size of legend to prevent title truncation ?

  1. #1
    Join Date
    Mar 2009
    Posts
    14
    Thanked 2 Times in 2 Posts

    Default How control size of legend to prevent title truncation ?

    Is there a way to control the legend size or legend margin in Qwt so that a string of a fixed length will always be visible?

    I am working on a real-time scrolling history plot that adds latest data sample to the right then scrolls time to the left.
    I want to append the current value to display in the legend title.


    Qt Code:
    1. // Create the plot curve
    2. plotCurve = new QwtPlotCurve("Vbattery 00.00");
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. // Update curve with latest sample and display value in legend
    2. void plotHistory::update(double newSample)
    3. {
    4. data[SeriesVsource].dataHistory[0] = newSample;
    5. data[SeriesVsource].curve->setTitle(m_formatter.sprintf("Vbattery %04.2f", newSample);
    6. }
    To copy to clipboard, switch view to plain text mode 

    Thanks in advance for any direction,

    -Ed
    Attached Images Attached Images
    Last edited by esutton; 23rd October 2012 at 16:35.

  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: How control size of legend to prevent title truncation ?

    Qt Code:
    1. virtual QWidget *YourCurve::legendItem() const
    2. {
    3. QWidget* w = QwtPlotCurve::legendItem();
    4. w->setMinimumWidth( ... );
    5.  
    6. return w;
    7. }
    To copy to clipboard, switch view to plain text mode 

    HTH,
    Uwe

  3. #3
    Join Date
    Mar 2009
    Posts
    14
    Thanked 2 Times in 2 Posts

    Default Re: How control size of legend to prevent title truncation ?

    I much appreciate the code sample. You solution works perfectly. Thank you Uwe!

    I did not realize your are the Qwt developer. Thank you so much for sharing your work! I can not imagine the amount of man hours that you must have put into developing such a fine widgets library. I kept wishing I was doing this charting application in C# .NET until I discovered your Qwt. I am looking forward to discovering more of what I can do with your Qwt widgets libraries. Thanks again!

    -Ed

Similar Threads

  1. Replies: 1
    Last Post: 14th October 2013, 07:07
  2. qwtPlot legend font size
    By Narciso in forum Qt Programming
    Replies: 2
    Last Post: 27th April 2012, 09:51
  3. Prevent Select Text in QWebView
    By wirasto in forum Qt Programming
    Replies: 3
    Last Post: 9th November 2010, 06:02
  4. Increase legend icon size?
    By torrentss in forum Qwt
    Replies: 2
    Last Post: 1st September 2010, 12:26
  5. Replies: 1
    Last Post: 24th October 2006, 16:40

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.