Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to make QLegend scrollable?

How to make QLegend scrollable?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtchartqlegendqgraphicsview
1 Posts 1 Posters 732 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    Filippov
    wrote on last edited by Filippov
    #1

    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:
    9 of 20

    12 of 20:
    12 of 20

    1 Reply Last reply
    1

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved