How to make QLegend scrollable?
Unsolved
General and Desktop
-
I have to have lots of QLineSeries in my QChart. But height of QChartView isn't enough to place QLegendMarker for all of them, so I can see some first markers and haven't any control to see others. And I don't know how make legend scrollable.
#include <QApplication> #include <QtCharts> int main(int argc, char *argv[]) { QApplication a(argc, argv); QChartView charView; QChart chart; charView.setChart(&chart); for(int i=0; i<20; ++i) { QLineSeries *series = new QLineSeries(&chart); for(int x=0; x<30; ++x) { series->append(x, qrand()%10+i*10); } series->setName(QString("testLine_%1").arg(i)); series->setColor(QColor(qrand()%255,qrand()%255,qrand()%255)); chart.addSeries(series); } chart.createDefaultAxes(); auto l = chart.legend(); if(l) l->setAlignment(Qt::AlignRight); charView.show(); return a.exec(); }
9 of 20:
12 of 20: