Solved TableView only ever queries column 0
I have a simple table model written in C++, and I attached a QML TableView to it. I noticed that the TableView only ever queried data for column 0, which seems odd (I do return the correct number of columns, and that number is queried).
From some examples, I concluded that the TableView get the columns through querying different roles for column 0, so I was able to adapt my model to a ListModel, assign different roles to the columns, and get it to work that way.
My question: Is the TableView supposed to query only column 0? Is the implementation of columns in term of roles instead of column index the "state of the art" philosophy for table-like models?
Are columns in table models only kept for compatibility reasons, then?
no, a QML tableview just differs from the QtWidgets tableview implementation
That would mean I would have to implement my model differently, depending on whether my UI uses widgets or QML. There goes my loose coupling...
You could implement a proxymodel exposing the columns of your original model (used directly in widgets) as roles for QML.
I'm suprised there isn't already one on GitHub or elsewhere.
Also you might want to know that there is a new QML TableView in the making, it will be able to handle different columns, it's not yet ready for release though.
I have found a relatively simple way to create a model that serves both kinds of views equally well, base on this thread.
Thanks for letting me know about the new view in-the-making. Unfortunately, I realized that Qt Quick Controls 2 are not particularly useful for me, because they lack native OS styling.