Results 1 to 6 of 6

Thread: Display own widget in new window

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2016
    Location
    Poland
    Posts
    18
    Thanks
    5
    Qt products
    Qt5
    Platforms
    Windows

    Question Display own widget in new window

    Hi.
    I want to do, when I click pushButton it should show new window with my widget (pie chart)

    I have something like this

    Qt Code:
    1. MainWindow::on_PieChart1_pushButton_clicked()
    2. {
    3. QPieSeries *series = new QPieSeries();
    4. series->append("Jane", 1);
    5. series->append("Joe", 2);
    6. series->append("Andy", 3);
    7. series->append("Barbara", 4);
    8. series->append("Axel", 5);
    9.  
    10. QPieSlice *slice = series->slices().at(1);
    11. slice->setExploded();
    12. slice->setLabelVisible();
    13. slice->setPen(QPen(Qt::darkGreen, 2));
    14. slice->setBrush(Qt::green);
    15.  
    16. QChart *chart = new QChart();
    17. chart->addSeries(series);
    18. chart->setTitle("Simple piechart example");
    19. chart->legend()->hide();
    20.  
    21. QChartView *chartView = new QChartView(chart);
    22. chartView->setRenderHint(QPainter::Antialiasing);
    23.  
    24. //here I need to make new window and put chartView inside
    25. }
    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?
    Last edited by time; 21st November 2016 at 21:21.

Similar Threads

  1. Replies: 1
    Last Post: 5th April 2013, 03:22
  2. Replies: 6
    Last Post: 9th November 2011, 04:31
  3. Replies: 2
    Last Post: 2nd November 2010, 15:52
  4. QMainWindow to display X Window
    By augusbas in forum Qt Programming
    Replies: 5
    Last Post: 21st July 2010, 14:00
  5. Move QT Window to different x display
    By jbpvr in forum Qt Programming
    Replies: 1
    Last Post: 5th September 2007, 20:28

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.