June 26, 2012

Immii Immii
Ant Farmer
233 posts

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

4 replies

June 27, 2012

Gerolf Gerolf
Area 51 Engineer
3210 posts

you are thinking weired.

Yes, it is a widget
Yes it is a view

If 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.

 Signature 

Nokia Certified Qt Specialist.
Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

June 27, 2012

Immii Immii
Ant Farmer
233 posts

@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?

June 27, 2012

Andre Andre
Area 51 Engineer
6031 posts

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.

 Signature 

Looking for Qt developers to join our team @ i-Optics: https://qt-project.org/forums/viewthread/25393/

June 28, 2012

Immii Immii
Ant Farmer
233 posts

Andre, Thanx this largely works

 
  ‹‹ Synchronization of mp3 tracks on Qt      Is there any minimizeEvent in Qt ››

You must log in to post a reply. Not a member yet? Register here!