Hello

I would like to sort my plot legend alphabetically. Therefore I imlemented following class inheriting from QwtLegend assuming that the virtual legendItems(void) method is called by the plot.
Qt Code:
  1. class Legend : public QwtLegend
  2. {
  3. public:
  4. Legend(QWidget* pParent = 0) : QwtLegend(pParent)
  5. {
  6. }
  7.  
  8. QList<QWidget*> legendItems(void) const
  9. {
  10. QList<QWidget*> lLegendItems = QwtLegend::legendItems();
  11. qSort(lLegendItems.begin(), lLegendItems.end(), Legend::lessThan);
  12. return lLegendItems;
  13. }
  14.  
  15. static bool lessThan(QWidget* pLi1, QWidget* pLi2)
  16. {
  17. if(pLi1 && pLi2)
  18. {
  19. if (pLi1->inherits("QwtLegendItem") && pLi2->inherits("QwtLegendItem"))
  20. {
  21. QwtLegendItem* lLabel1 = (QwtLegendItem*)pLi1;
  22. QwtLegendItem* lLabel2 = (QwtLegendItem*)pLi2;
  23. return lLabel1->text().text().toLower() < lLabel2->text().text().toLower();
  24. }
  25. }
  26. return false;
  27. }
  28. };
To copy to clipboard, switch view to plain text mode 
The legend is added to the plot...
Qt Code:
  1. Legend* lLegend = new Legend(mPlot->canvas());
  2. // some initialisations...
  3. mPlot->insertLegend(lLegend, QwtPlot::ExternalLegend);
To copy to clipboard, switch view to plain text mode 
But the legendItems(void) method is never called.
Any idea what's wrong?

Best Regards
Stefan