[英]How to disable update on a QQuickItem
I have a QQuickItem
derived class 我有一个
QQuickItem
派生类
// Class
class MyQQuickItem : public QQuickItem {
Q_OBJECT
}
// updatePaintNode in cpp function
QSGNode * MyQQuickItem::updatePaintNode(QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData) {
// draw UI logic
return node;
}
// QML component
MyQQuickItem {
id: my_quick
objectName: "myquickitem"
width : 500
height : 500
}
I am doing something on a separate UI which causes the updatePaintNode
of MyQQuickItem
to be fired. 我正在一个单独的UI上做某事,这会导致
MyQQuickItem
的updatePaintNode
被触发。 If I have a pointer to MyQQuickItem on cpp side like so, 如果我像这样在cpp端有指向MyQQuickItem的指针,
QQuickItem * my_quick_item_ptr = m_qml_engine->rootObjects()[0]->findChild<QQuickItem*>("myquickitem");
How can disable MyQQuickItem
's updatePaintNode from getting called when I don't want it to? 当我不希望
MyQQuickItem
的updatePaintNode被调用时,如何禁用它?
Secondary question: If yes, How to reinstate it back again? 第二个问题:如果是,如何再次将其恢复?
If and when updatePaintNode()
is called is most likely scenegraph internal stuff that wasn't really intended to be modified. 如果以及何时调用
updatePaintNode()
则很可能是场景图内部的东西,实际上并没有打算对其进行修改。
Maybe try doing something less invasive like: 也许尝试做一些侵入性较小的事情,例如:
QSGNode * MyQQuickItem::updatePaintNode(QSGNode * oldNode, UpdatePaintNodeData * updatePaintNodeData) {
if (doNotUpdate) return oldNode;
// draw UI logic
return node;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.