我需要的,從佈局清楚我chartViewers,但是當我做,我不能刪除最後一個小部件。 當我測試我的佈局的長度,我得到0,但是小工具仍是這裏的佈局更新後,如圖片:爲什麼佈局,不更新?
我在這裏的代碼時,我刪除了部件和圖
print("proceding to delete chart ", chartName, " at : ", indexGraph)
currentGraph = self.charts[indexGraph]
currentWidget = self.chartVs[indexGraph]
self.chartLayout.removeWidget(currentWidget)
self.chartVs.remove(currentWidget)
currentGraph.clearData()
self.charts.remove(currentGraph)
self.chartLayout.update()
#currentWidget.resetCachedContent()
listGraphs.remove(chartName)
self.refreshListWithOpt(self.chartTree, listGraphs, 1, optGraphs)
這裏是我創建的圖表,並將其添加到佈局的代碼:
self.charts.append(chartClass(patientStr, exp))
print("\nNew Plot chart ", self.charts[lastIndex].name, " length : ", lastIndex)
listGraphs.append(self.charts[lastIndex].name)
print("list Graphs : ", listGraphs)
self.charts[lastIndex].plotJSON(myData.plot(patientStr, exp))
self.chartVs.append(QChartView(self.charts[lastIndex]))
self.chartVs[lastIndex].setRenderHint(QPainter.Antialiasing)
self.chartLayout.insertWidget(0, self.chartVs[lastIndex])
什麼建議嗎?
這個問題並不清楚。 –
阿祖爾AGMA Ghilas,我的問題是與最後一個控件,當我刪除它,它仍然存在於我的佈局,甚至是所有我做了什麼,直到如今。 –
嘗試:'currentWidget.deleteLater()' – eyllanesc