How to populate form asynchronously
-
I have succesfully built an QAbstractItemModel which populates my view asynchronously. Each cell of the view holds a SUMMARY of an ITEM (row) in my database.
I know which to edit the ITEM, and need to retrieve ALL fields from the row, and populate a larger form. My model above is of summary data only.
What is the right way to populate the form asynchronously? Do I have to make another model with ALL fields? (That feels wrong somehow).
-
I have succesfully built an QAbstractItemModel which populates my view asynchronously. Each cell of the view holds a SUMMARY of an ITEM (row) in my database.
I know which to edit the ITEM, and need to retrieve ALL fields from the row, and populate a larger form. My model above is of summary data only.
What is the right way to populate the form asynchronously? Do I have to make another model with ALL fields? (That feels wrong somehow).
-
@eyllanesc I don't have an example because I'm still at the design stage. But I'll try to rephrase.
My QAbstractItemModel works great when populating a view with many items. Now, I need to populate a single form, with the data from a single row of my database, for editting.
The QAbstractItemModel seems like overkill for this. I just need to retrieve the data and fill in the form. But this must be asynchronous because the source of the data is across the internet.
What mechanism should I use to fetch the data and populate the form when ready. The QAbstractItemModel seems too complex (though I imagine it would work). I'm not sure what else is available for this type of scenario.
-
@eyllanesc I don't have an example because I'm still at the design stage. But I'll try to rephrase.
My QAbstractItemModel works great when populating a view with many items. Now, I need to populate a single form, with the data from a single row of my database, for editting.
The QAbstractItemModel seems like overkill for this. I just need to retrieve the data and fill in the form. But this must be asynchronous because the source of the data is across the internet.
What mechanism should I use to fetch the data and populate the form when ready. The QAbstractItemModel seems too complex (though I imagine it would work). I'm not sure what else is available for this type of scenario.
@ocgltd said in How to populate form asynchronously:
@eyllanesc I don't have an example because I'm still at the design stage. But I'll try to rephrase.
My QAbstractItemModel works great when populating a view with many items. Now, I need to populate a single form, with the data from a single row of my database, for editting.
The QAbstractItemModel seems like overkill for this. I just need to retrieve the data and fill in the form. But this must be asynchronous because the source of the data is across the internet.
It sounds like the program has already retrieved the data, converted it into a model, and used a view to select an element from the model. Why not use the same model again? The view used to select the data of interest should provide a current or selected QModelIndex. The secondary view can either be another QAbstractItemView which displays the same index, or directly use QAbstractItemModel::data().