Ok I succeeded in adding entries by:
void addToLegend(const QString & key, const QStringList & what, QwtAbstractLegend *const legend)
{
QList<QwtLegendData> list;
for(QStringList::const_iterator it = what.begin(); it != what.end(); it++) {
QwtLegendData data;
data.setValue(QwtLegendData::Role::TitleRole, QVariant(*it));
list << data;
}
legend->updateLegend(QVariant(key), list);
}
then I do:
QStringList le;
le.append("hello");
le.append("bicycle");
le.append("1");
addToLegend("key", le, graph -> legend());
Unfortunately when calling this, say, two times, the layout gets messed up: the order of the items becomes seemingly random.
Is there a way in which I can either sort them or keep them in the same order as added?
I also tried adding items individually and them giving them a key-in-order (a, b, c, etc) but that did not help.
Bookmarks