How to repaint QWidget encapsulated in QDeclarativeItem in QML?
-
@p3c0 What's more interesting: If I call
addFlowfrom QML, it works (replots). But if I call it from C++, it updates theQWidget, but not the QML Item. Even if I callrefresh()from QML right after it, which should replot and repaint the QML Item too. Any explanation to this? Why is there a difference between changing the QWidget in the C++ code and asking for a replot from QML and doing everything in QML? As if the QML Item and the C++ QDeclarativeItem were two independent objects.So now my plan is to give the flow value from C++ to the
FlowGrafikQML item, and then calladdFlowfrom QML. That should work.@Chillax Unfortunately I too dont understand this behavior. The fact that it works in desktop environment and not on embedded only points that there should be some bug in that environment.
So now my plan is to give the flow value from C++ to the FlowGrafik QML item, and then call addFlow from QML.
Try. I had suggested the same earlier :)
Let us know if it works or if possible the exact reason so that it may help others too. -
@Chillax Unfortunately I too dont understand this behavior. The fact that it works in desktop environment and not on embedded only points that there should be some bug in that environment.
So now my plan is to give the flow value from C++ to the FlowGrafik QML item, and then call addFlow from QML.
Try. I had suggested the same earlier :)
Let us know if it works or if possible the exact reason so that it may help others too.@p3c0 So thanks a lot for the help! I would have given up without you :) The problem was that I created two instances of
FlowGrafik. One in the QML and one in C++. I changed the C++ one and expected the QML one to refresh.Now I created a pointer in the C++ code that points to the Item in the QML.
QmlApplicationViewer flowView; flowView.setSource(QUrl("qrc:///qml/qml/FlowView.qml")); QObject * flowViewObject = flowView.rootObject(); FlowGrafik * flowGrafik = flowViewObject->findChild<FlowGrafik *>(QString("FlowGrafik"));But now if I want to use this pointer (like
flowGrafik->addFlow(...)) I get a segmentation fault. Do you know why? -
@p3c0 So thanks a lot for the help! I would have given up without you :) The problem was that I created two instances of
FlowGrafik. One in the QML and one in C++. I changed the C++ one and expected the QML one to refresh.Now I created a pointer in the C++ code that points to the Item in the QML.
QmlApplicationViewer flowView; flowView.setSource(QUrl("qrc:///qml/qml/FlowView.qml")); QObject * flowViewObject = flowView.rootObject(); FlowGrafik * flowGrafik = flowViewObject->findChild<FlowGrafik *>(QString("FlowGrafik"));But now if I want to use this pointer (like
flowGrafik->addFlow(...)) I get a segmentation fault. Do you know why?@Chillax Thank you :)
The problem was that I created two instances of FlowGrafik. One in the QML and one in C++. I changed the C++ one and expected the QML one to refresh.
but now this makes me wonder as to why it worked on desktop.
But now if I want to use this pointer (like flowGrafik->addFlow(...)) I get a segmentation fault. Do you know why?
Was the
FlowGrafikobject found ? You can add a small condition to verify it.if(flowGrafik) { flowGrafik->addFlow(...) } -
@Chillax Thank you :)
The problem was that I created two instances of FlowGrafik. One in the QML and one in C++. I changed the C++ one and expected the QML one to refresh.
but now this makes me wonder as to why it worked on desktop.
But now if I want to use this pointer (like flowGrafik->addFlow(...)) I get a segmentation fault. Do you know why?
Was the
FlowGrafikobject found ? You can add a small condition to verify it.if(flowGrafik) { flowGrafik->addFlow(...) } -
@p3c0 You are right, it was not found, because it was actually the rootobject, not a child :) Thanks again for the help!