I'm sorry to tell that QStringListModel is a very simple model interface wrapper around given string list. It is not capable of holding separate header data. You'd have to subclass and store header data yourself. Or switch to QStandardItemModel.
J-P Nurmi
It would be an overkill. QStringListModel is meant to be used with QListView which doesn't show headers.
If you need headers, subclass the model and reimplement headerData(). Currently your approach is "man, that tcp socket sucks - it can't even make coffee!"
Well, I wouldn't go as far as use that wording. Better wording would be, gee this socket stuff sucks, it won't let me perform icmp requests (disclaimer: I used this as an example. I don't know if the socket classes actually let you do icmp or not).
In defense of overkill, from reading all that I have about Model/View programming, the point is that you make models and you make views with the point that you can display the same data set in various ways using different views. With that in mind, I would think that a model should be written with at least the basic functionality to have it work with the various views.
With that said, I will reimplement the model to show the header.![]()
In general you wouldn't use headers for one column "lists" the same way as you wouldn't title rows with numbers if you only have one row (I mean you wouldn't make it a list at all). There are some design rules that should be followed and that's a perfectly valid argument in favour of the string list model not having headers. I don't say this is the case - I'd say simplicity was the crucial argument here.
Bookmarks