mardi 25 septembre 2018

Qchart exception triggered

I'm developing an application that shows 3 charts in the main window and everything works fine. but now I came across an error when I make the instance of the main window inside the class of another window the application crush and when do the debugger shows an exception triggered in one of the chars.

eu utilizei um graphic view and promote to Qchartview e paa cada chart o codigo é este:

chart_1

QPieSlice *slice = pieSeries->slices().at(0);
   QFont font = slice->labelFont() ;
        font.setBold(true);
        font.setPointSize(15);

        slice->setExploded();
        slice->setLabelVisible();
        slice->setPen(QPen(Qt::darkGreen, 1));
        slice->setBrush(Qt::darkBlue);
        slice->setLabelFont(font);

        QChart *chart = new QChart();
        chart->addSeries(pieSeries);
        chart->setTitle("<h2>Total money of each currency</h2>");
        chart->setAnimationOptions(QChart::SeriesAnimations);
        chart->legend()->setVisible(true);
        chart->legend()->setAlignment(Qt::AlignBottom);

        pieSeries->setLabelsVisible();
        pieSeries->setLabelsPosition(QPieSlice::LabelOutside);

        for(auto slice : pieSeries->slices())
        slice->setLabel(QString("%1%").arg(100*slice->percentage(), 0, 'f', 1));

        ui->chartView_1->setChart(chart);
        ui->chartView_1->setRenderHint(QPainter::Antialiasing); 

chart_2

QChart *donutBreakdown = new QChart();
        donutBreakdown->setAnimationOptions(QChart::AllAnimations);
        donutBreakdown->setTitle("<h2>Cassettes Information</h2>");
        donutBreakdown->legend()->setAlignment(Qt::AlignBottom);
        donutBreakdown->addSeries(series1);
        donutBreakdown->addSeries(pieSeriesPie2);
        donutBreakdown->addSeries(series3);

        pieSeriesPie2->setLabelsVisible();
        pieSeriesPie2->setLabelsPosition(QPieSlice::LabelOutside);

        double arm = 0.04;
        for(int i = 0; i < pieSeriesPie2->count(); i++){
            double arm = (double)i/24;
           double arm2= i*0.040;

                QPieSlice *slice1 = pieSeriesPie2->slices().at(i);
                slice1->setLabelArmLengthFactor(arm2);

               m_slice = static_cast<CustomSlice *>(slice1);
                m_slice->setLabelArmLengthFactor(arm2);
        }
        ui->chartView_2->setChart(donutBreakdown);
        ui->chartView_2->setRenderHint(QPainter::Antialiasing);

the two charts are pie chart and the triggered exception is on chart_2 I already replaced the chart_2, already replaced the graphical view that I am using in form

the days that I am fighting this error. please help me please

Aucun commentaire:

Enregistrer un commentaire