我需要的,从布局清楚我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