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. Chart height was changed automatically when did attach multiple axis.
Forum Updated to NodeBB v4.3 + New Features

Chart height was changed automatically when did attach multiple axis.

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 368 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.
  • yanagidaY Offline
    yanagidaY Offline
    yanagida
    wrote on last edited by
    #1

    Hello,

    I'm trying make multi chart.
    To start with, I changed the following example chart.

    http://doc.qt.io/QtCharts/qtcharts-multiaxis-main-cpp.html

    int main(int argc, char *argv[])
    {
        ...
        QCategoryAxis *axisY3 = new QCategoryAxis;
        axisY3->append("Low", 5);
        axisY3->append("Medium", 12);
        axisY3->append("High", 17);
        axisY3->setLinePenColor(series->pen().color());
        axisY3->setGridLinePen((series->pen()));
    
        chart->addAxis(axisY3, Qt::AlignRight);
        series->attachAxis(axisX);
        series->attachAxis(axisY3);
        
        //Added code
        series = new QSplineSeries;
        chart->addSeries(series);
        QValueAxis *axisY4 = new QValueAxis;
        axisY4->setLinePenColor(series->pen().color());
        chart->addAxis(axisY4, Qt::AlignLeft);
        series->attachAxis(axisX);
        series->attachAxis(axisY4);
        ...
        Add to axis the axis10 from axis5.
        ...
        series = new QSplineSeries;
        chart->addSeries(series);
        QValueAxis *axisY11 = new QValueAxis;
        axisY11->setLinePenColor(series->pen().color());
        chart->addAxis(axisY11, Qt::AlignLeft);
        series->attachAxis(axisX);
        series->attachAxis(axisY11);
        //Added code
    
        QChartView *chartView = new QChartView(chart);
        chartView->setRenderHint(QPainter::Antialiasing);
    
        QMainWindow window;
        window.setCentralWidget(chartView);
        window.resize(800, 600);
        window.show();
    
        return a.exec();
    }
    

    As a result, chart height was changed automatically.
    I know that, can adjust chart height by call the "chart->setMaximumHeight(500)".
    I made the Dynamic multi-scroll chart(using the setMaximumHeight()).But, chart height was changed automatically when chart was scrolled.

    Please teach me the proper way to set the height of the chart .

    1 Reply Last reply
    0

    • Login

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