C++ 当一个C++;插槽函数尝试与它从QML获得的输入进行交互
我有类似的东西导致我的程序崩溃C++ 当一个C++;插槽函数尝试与它从QML获得的输入进行交互,c++,qt,qml,qt5,C++,Qt,Qml,Qt5,我有类似的东西导致我的程序崩溃 void BackEnd::updateChart(QtCharts::QChartView *view) { QList<QObject*> children = view->children(); } 其中,“后端”是QT对象“后端”的实例,“图表视图”是QML类型“图表视图”的实例 我尝试在我的后端构造函数上运行以下内容,但是没有帮助 qRegisterMetaType<QtCharts::QChartView*>()
void BackEnd::updateChart(QtCharts::QChartView *view)
{
QList<QObject*> children = view->children();
}
其中,“后端”是QT对象“后端”的实例,“图表视图”是QML类型“图表视图”的实例
我尝试在我的后端构造函数上运行以下内容,但是没有帮助
qRegisterMetaType<QtCharts::QChartView*>();
qRegisterMetaType();
ChartView
不是QChartView
,ChartView
是私有api的QQuickItem
,它处理与QChartView相同的数据,但不是QChartView
。因此,解决方案是将QtCharts::QChartView
更改为QQuickItem
或QObject
void BackEnd::updateChart(QQuickItem /*or QObject*/ *view)
{
QList<QObject*> children = view->children();
}
您调试过正在发生的事情吗?非常感谢,我希望我能事先了解QDebug。
void BackEnd::updateChart(QQuickItem /*or QObject*/ *view)
{
QList<QObject*> children = view->children();
}
QtCharts::DeclarativeChart(0xfoo_address, parent=0x0, geometry=0,0 400x300)