0

I am training on Qt, and playing with different elements. Right now, I have a ListView whose model comes from a C++ backend, using setContextProperty on a QVariant::fromValue applied to a QList. That list is refreshed somewhat randomly, elements come and go.

On clicking an element, my delegate opens a dialog, providing more information, action buttons etc... to apply to that element. This works fine, except that any model update closes that dialog, as the whole list gets refreshed.

Is there a way to set aside the element I'm looking at in the QML side (knowing that the model update can delete this element from my list at any time), to have the time I need to inspect it and interact with the dialog box?

Will59
  • 1,430
  • 1
  • 16
  • 37
  • If you want us to help you, you must provide a [mcve] of your problem. – eyllanesc Feb 21 '18 at 23:49
  • 1
    Don't use QList as a model in production, it is very inefficient. The model cannot change without the view rebuilding everything. Implement a proper list model. If you use `QObject` derived model items, you can use this one: https://stackoverflow.com/questions/35160909/how-to-create-a-generic-object-model-for-use-in-qml – dtech Feb 21 '18 at 23:54
  • You can refer this [demo](https://github.com/arkceajin/QmlListModel) for C++/QML list data operation, and post your code to explain the problem. – JustWe Feb 22 '18 at 09:03
  • I would recommend using this model http://gitlab.unique-conception.org/qt-qml-tricks/qt-qml-models if you need proper roles and data changed signal and a proper list api. – GrecKo Feb 22 '18 at 09:39

0 Answers0