Platform - Linux x86_64
Qt Version - 5.9.3
fontHeight produced a integer value +/- 56
iconHeight produced an integer value ( < fontHeight)
The Role's where not the problem. Please see my updated delegate below (kudos for calling it, the delegate being the problem)
Well this is embarrasing. I did not fully realize what I was coding until I had battled with the delegate all night.
I understood that I was coding a template, and assumed that on each item which was added, the origin remained at [0,0]. This was not the case as there was an offset added of value specified in the sizeHint (in my case, 56). Thus all my QListView's QStandardItem's were in fact there, but drawn over each other.
After changing values and experimenting over a long period (a number of hours), I finally came to the desired result, shown below.
Also, I need to thank scopchanov for his hint into this offset problem
My second and main question is then : how to implement correct drag and drop operations with custom QStandardItem which needs to own custom data ?
With the standard item widgets/models you can't drag-n-drop custom item roles.
This makes sense, since the model doesn't know which UserRole+ was set.
It would need to iterate all possible item-role values when creating the drop-data.
The only solution i see is to create your own custom model and reimplement the needed drag-n-drop methods. This also give you full control over your data structure storing the data inside the model.
This is more work, but you will learn a lot and gain some performance (by avoiding the standard-item classes)
The things you have to understand with hierarchical model are:
everything can be done through items
use appendRows (or insertRows) to add one line containing several columns
create a hierarchy on the item that represents the first column with the above appendRows (for instance on "(fffe,e000)" but not on "SQ")
use appendRows (or insertRows) on top level instances only to your model (for instance "(0040,a493)" "CS", "(0040,a504)" "SQ", but not "(0008,0105)" "CS")
To view your hierarchy, create a QTreeView and give it this model.