Hi.
I want to do, when I click pushButton it should show new window with my widget (pie chart)
I have something like this
MainWindow::on_PieChart1_pushButton_clicked()
{
QPieSeries *series = new QPieSeries();
series->append("Jane", 1);
series->append("Joe", 2);
series->append("Andy", 3);
series->append("Barbara", 4);
series->append("Axel", 5);
QPieSlice *slice = series->slices().at(1);
slice->setExploded();
slice->setLabelVisible();
slice
->setPen
(QPen(Qt
::darkGreen,
2));
slice->setBrush(Qt::green);
QChart *chart = new QChart();
chart->addSeries(series);
chart->setTitle("Simple piechart example");
chart->legend()->hide();
QChartView *chartView = new QChartView(chart);
chartView
->setRenderHint
(QPainter::Antialiasing);
//here I need to make new window and put chartView inside
}
MainWindow::on_PieChart1_pushButton_clicked()
{
QPieSeries *series = new QPieSeries();
series->append("Jane", 1);
series->append("Joe", 2);
series->append("Andy", 3);
series->append("Barbara", 4);
series->append("Axel", 5);
QPieSlice *slice = series->slices().at(1);
slice->setExploded();
slice->setLabelVisible();
slice->setPen(QPen(Qt::darkGreen, 2));
slice->setBrush(Qt::green);
QChart *chart = new QChart();
chart->addSeries(series);
chart->setTitle("Simple piechart example");
chart->legend()->hide();
QChartView *chartView = new QChartView(chart);
chartView->setRenderHint(QPainter::Antialiasing);
//here I need to make new window and put chartView inside
}
To copy to clipboard, switch view to plain text mode
So how to write it, to show new window with my pie chart when I click the push button?
I know you can use setCentralWidget(QWidget *widget) but it works only with mainWindow. I need it in new window. Any ideas?
Bookmarks