ItemView (QHeaderView)
-
Hi there, can any one please give me some code snippet how can I add a combBox in my listview header.
I am also thinking since qheaderview is a widget why cant I subclass it and put combobox in layout and set that layout in this header? or am I thinking weird -
you are thinking weired.
Yes, it is a widget
Yes it is a viewIf you just add a combo box, it is not shown in the headers.
A herader view is a QAbstractItemView, so you can use an item delegate for that or any other view method from that class. -
@Gerolf: Indeed me too realized it is weired idea. so I endup writing itemDelegate and re implemented few virtual function including createEditor() and returned comboBox as editor but this has no effect but then I read the details of the Qt document of Qheaderview and that says that itemDelegate will not work with headerview.
Now I am lost, only thing I can read here and there is to paint the section but I dont know how to do that and even if I manage to paint who is going to manage the items of the combobox and many other signals and slot etc of a general combobox you can think of.Guys any idea? code snippet ? example? pointer?
-
Indeed, Gerolf's suggestion was off. You cannot use delegates for header views.
The only thing you can do, is create the combo box as a child of the HeaderView, and position it manually. QHeaderView has some functions that allow you to figure out where each section of the header is, and what their sizes are.
-
Andre, Thanx this largely works