in the meanwhile I have solved the problem of accessing the data, and I could change my function
Qt Code:
  1. setMarkerOnMax( double* xData, double* yData, int dataCount, int precision, Qt::Alignment alignment )
To copy to clipboard, switch view to plain text mode 
to
Qt Code:
  1. setMarkerOnMax( int precision, Qt::Alignment alignment )
To copy to clipboard, switch view to plain text mode 
This work well as long as I have only one curve attached to the plot.

In the case I have several curve attached to the plot, and I don´t want to identify all maxima, but only that of one curve for example, I have to add an overloaded function
Qt Code:
  1. setMarkerOnMax( double* yData, int precision, Qt::Alignment alignment )
To copy to clipboard, switch view to plain text mode 
yData beeing the pointer onto the data whose maximum has to be labeled.

To do so, I have the problem of identifying which curve of the list belongs to the yData (C-array)

As starting point, I have the list of all curves attached to the plot.

One solution would be to calculate an hash of the data of each curve in the list and compare them with the hash of the data yData passed as argument - see code fragment below -.

This will work but seems to me to be an overkill!

Is there a better method?

Alain

Qt Code:
  1. void setMarkerOnMax( double* yData, int precision, Qt::Alignment alignment )
  2. {
  3. QwtPlotItemIterator it;
  4. const QwtPlotItemList& itemList = this->itemList();
  5. QwtPlotItemList curveList;
  6. // select the plotItem
  7. for ( it = itemList.begin(); it != itemList.end(); ++it ) {
  8. if ( (*it)->rtti() == QwtPlotItem::Rtti_PlotCurve ) {
  9. curveList += *it;
  10. }
  11. }
  12. // calculate an hash of each curve for identification
  13. for ( unsigned int i = 0; i < curveList.count(); ++i ) {
  14. QwtPlotCurve* curve = static_cast<QwtPlotCurve *>( curveList[i] );
  15. // compute some hash data for each curve
  16. }
  17. // compare the hash of each curve with hash of C-array yData passed as argument
  18. // to get the index of curveList corresponding to yData
  19. // label the curve with the right index
  20. }
To copy to clipboard, switch view to plain text mode