paceholder / nodeeditor

Qt Node Editor. Dataflow programming framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to lazily initialize embeddedWidget in NodeDelegateModel?

QiuYilin opened this issue · comments

Noted the code comment,It seems it's better to deffer the creation of embedded widget in member function.

    /**
   * It is recommented to preform a lazy initialization for the
   * embedded widget and create it inside this function, not in the
   * constructor of the current model.
   *
   * Our Model Registry is able to shortly instantiate models in order
   * to call the non-static `Model::name()`. If the embedded widget is
   * allocated in the constructor but not actually embedded into some
   * QGraphicsProxyWidget, we'll gonna have a dangling pointer.
   */
    virtual QWidget *embeddedWidget();

However, If I create embedded widget lazily and then change the content ,the corresponding QGraphicsProxyWidget won't update.

And embedded widget initialized in the constructor like the resizable_images example works well.

So what's the correct way to lazily initialize embeddedWidget in NodeDelegateModel?

Noted the code comment,It seems it's better to deffer the creation of embedded widget in member function.

    /**
   * It is recommented to preform a lazy initialization for the
   * embedded widget and create it inside this function, not in the
   * constructor of the current model.
   *
   * Our Model Registry is able to shortly instantiate models in order
   * to call the non-static `Model::name()`. If the embedded widget is
   * allocated in the constructor but not actually embedded into some
   * QGraphicsProxyWidget, we'll gonna have a dangling pointer.
   */
    virtual QWidget *embeddedWidget();

However, If I create embedded widget lazily and then change the content ,the corresponding QGraphicsProxyWidget won't update.

And embedded widget initialized in the constructor like the resizable_images example works well.

So what's the correct way to lazily initialize embeddedWidget in NodeDelegateModel?

I found the issue #271