My approach was pretty much as such:
Chart.qml:
Window {
ChartView {
id: chartView
// ...
}
Button {
text: "save"
onClicked: manager.save(chartView)
}
}
Manager.py:
class Manager(QObject):
@pyqtSlot(QObject)
def save(self, chartview):
img = chartview.grab()
img.save(MY_DEFAULT_PATH)
The problem is, of course, that inside the Manager.save() the chartview is equivalent of C++'s QObject* which does not have the 'grab' method. But it could be downcasted to QChartView* (or at least QWidget*) which, such method, has. In C++ I would do it probably with qobject_cast.
My questions are:
- Is such downcasting doable in PyQt?
- If not - do you have any idea how could it be done differently?