I should use the delete chartView somewhere near end of function?
No. If you don't want a memory leak, then create the QChartView with the MainWindow as a parent. The chart view will then be deleted when the main window is deleted, whether the chart view is visible or not.