Keyboard: 2 dimesional with ListView/TableView?
I'd like to build a virtual Keyboard in QML with a Keyboard-Layout defined in cpp with a QStandardItemModel. Every item has a few attributes like "lower character", "upper character", "special character", "color" and so on... The items/keys are arranged in columns and rows in the QStandardItemModel.
Now my question is how do I map this 2D model to an view with a delegate like in ListView. My understanding of the ListView Control is that it can only handle 1D models. When I assign my 2D model to a ListView it only shows the first Column. Is there a way to tell ListView to use the second Column or maybe to show just a row of items from the model?
I also looked at TableView but, if I see it corecctly, it also just support one dimensional models and spreads the rolename of one item over several columns...
GridView won't help either because it shows just the first column of the model (like ListView)
What would you recommend me to do?
So... why not change your model to be 1D too? If you put the keys in the right order, you can arrange them using a GridView with the right number of columns it seems to me.
that would be my last resort.... creating five QStandardItemModels and assigning them to five different ListViews each for every row....
But I was wondering if it would be possible by just using one QStandardItemModel?
Thanks for your answer Andre!
It can still be a single model!
Just add a property to the model that exposes the number of columns to use, and bind the number of columns of your GridView to this property (ok, indirectly via the cellWidth and cellHeight properties).