1

I have a QQuickItem derived class like below

class MyQQuickItem : public QQuickItem 
{
  Q_OBJECT
public:
  MyQQuickItem(QQuickItem *parent = 0);
  ~ MyQQuickItem();

  QSGNode *updatePaintNode(QSGNode *, UpdatePaintNodeData *);
};

I have my own TextureNode class as well.

I have MyQQuickItem registered on QML side & embedded in main.qml like below.

MyQQuickItem {
    id: my_quick_item
    objectName: "MyQQuickItemObject"
    visible: false
    width: 500
    height: 500
}

On the trigger of a certain signal, that I have connected to a slot in MyQQuickItem, I call this->update(). This of course triggers updatePaintNode & I am able to repaint my MyQQuickItem with new content I want.

Is it possible to trigger updatePaintNode on a QQuickItem without declaring it at all in a qml file?

I want to dynamically create my MyQQuickItem at C++ level & not have it defined or declared at all in main.qml How can I do this?

Core question: How can I create a QQuickItem purely at C++ level which is updatable with new content by calling update on it so that updatePaintNode is fired?

Update: I am able to create a QQuickItem in the following way.

QQuickView * view = new QQuickView;
view->setSource(QUrl(QStringLiteral("qrc:/MyQQuickItem.qml")));
QQuickItem * myquickitem_object = view->rootObject();

But the problem is that I cant get updatePaintNode to fire when I call this->update. What should I do get the my QQuickItem to update itself?

TheWaterProgrammer
  • 7,055
  • 12
  • 70
  • 159
  • I think you don't need QQuickItem without displaying it in UI via QML. And if you want an access from C++ to the quick item used by QML is a different question. – Alexander V Aug 21 '17 at 18:28
  • You've been posting a series of questions that hint at you doing something wrong. – dtech Aug 21 '17 at 19:01
  • @dtech hahaha. whats wrong with this question? – TheWaterProgrammer Aug 21 '17 at 19:01
  • is it not possible to to update a `QQuickItem` without putting it on QML? – TheWaterProgrammer Aug 21 '17 at 19:02
  • Well, what good is a QML item without a QML engine and without a QML scenegraph renderer? Maybe you should clarify what you want to do rather than wasting time on things impossible. – dtech Aug 21 '17 at 19:12
  • I explained the background in above comment. it all boils down to **1.** whether I can create `MyQQuickItem` on the fly in C++ only? **2.** Or have `MyQQuickItem.qml` in my library & somehow make it capable of updating itself. note that I don't need to display `MyQQuickItem` on app's UI & I do have access to QMLEngine in my library – TheWaterProgrammer Aug 21 '17 at 19:24

0 Answers0