Model View customized requirement
-
Hi All,
Initial project requirement was as below,
Hence I used GridView to implement this.
But now the requirement is changed, the expectation is
But its expected we follow the index such as
p1 = 0'th index,
p2 = 1st index,
p3 = 2nd index,
p4 = 3rd index,
p5 = 4th index,
p6 = 5th index,
p7 = 6th index.The model data comes from C++ backend. currently backend is implemented by sub classing QAbstractListModel.
Please let me know, how to approach this problem.
Thanks!
-
@fcarney : But those empty data also have index. I don't want index to be associated with empty data.
-
If not possible with GridView, is there any other model view using which this can be achieved ?
-
Will you always have only 7 items? Should it only be the layout you displayed or the empty cells can shift?
-
@fcarney : But those empty data also have index. I don't want index to be associated with empty data.
@Vinoth-Rajendran4 said in Model View customized requirement:
But those empty data also have index. I don't want index to be associated with empty data.
So what exactly do you want then?
Anyway, ISTM you have two choices:
- Subclass/derive from some
QLayout
(e.g. possiblyQGridlayout
) and implement your desired layout with "blank" cells. - Interpose a
QAbstractProxyModel
-derived class (QIdentityProxyModel
should be a good starting point) and have that deal with the indexes so that it returns "invalid index" where you want blanks in theQGridLayout
. This means that while the proxy model returns some blank indexes your underlying model does not have to have such "gaps" in it.
EDIT
Oh, I'm so sorry, I only just noticed this isGridView
/QML, not widgets application. I will leave the above in, I don't know is is meshes with how to do things in QML...? Hopefully the second option is still applicable? - Subclass/derive from some
-
Will you always have only 7 items? Should it only be the layout you displayed or the empty cells can shift?
@GrecKo : empty cells can shift dynamically.
-
How are the cell positions determined?
A GridLayout + a Repeater could work.