PDA

View Full Version : How control size of legend to prevent title truncation ?



esutton
23rd October 2012, 15:43
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.



// Create the plot curve
plotCurve = new QwtPlotCurve("Vbattery 00.00");



// Update curve with latest sample and display value in legend
void plotHistory::update(double newSample)
{
data[SeriesVsource].dataHistory[0] = newSample;
data[SeriesVsource].curve->setTitle(m_formatter.sprintf("Vbattery %04.2f", newSample);
}


Thanks in advance for any direction,

-Ed

Uwe
23rd October 2012, 23:09
virtual QWidget *YourCurve::legendItem() const
{
QWidget* w = QwtPlotCurve::legendItem();
w->setMinimumWidth( ... );

return w;
}

HTH,
Uwe

esutton
26th October 2012, 16:26
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