[Qt-interest] QHeaderView with widgets

Daniel Lipovetsky daniel.lipovetsky at gmail.com
Mon Jun 29 07:43:32 CEST 2009


I am a new Qt user and am unsure of how to best implement a horizontal
QHeaderView that displays not only a label for each header section, but
displays an editable widget (e.g. QLineEdit) below each label. I have
attached an example snapshot of this implementation as a reference.

So far, I can think of doing the above in two ways:

1. Subclass QHeaderView and re-implement paintSection(), using the
drawControl()/drawComplexControl() methods to draw a CT_LineEdit control
below the label currently drawn. I believe I'd have to implement the
behavior a QLineEdit by myself (cursor painting, text entry, signals, etc).

2. Subclass QHeaderView and create a QLineEdit widget on top of each header
section, using the sectionSizeHint to make sure each widget appears in its
correct place. I'd have to connect QLineEdit widget to the model used by the
QHeaderView.

I would appreciate any advice you may have; whether one of the above ways is
preferable, or whether neither is a good approach to the problem. I think
that, were item delegates used by QHeaderView, I could use them to implement
the above, but I don't think I could re-implement a QHeaderView that uses
item delegates.

Thank you,
Daniel

P.S. I know that others have asked my question
before<http://lists.trolltech.com/qt-interest/2006-05/thread00010-0.html>,
but I have not been able to find a comprehensive response--if anyone can
point me to one already out there, I would appreciate it.

P.P.S. I am aware that QICSTable allows widgets to be used in the table
header, but since I am not a professional developer, it does not make sense
for me to license that widget; neither am I working on any GPL'd
software--I'm just learning Qt. If I find myself going down the right path
and create a worthwhile implementation, I would be more than happy to share
it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090628/f4d7b820/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mockup.jpg
Type: image/jpeg
Size: 20463 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090628/f4d7b820/attachment.jpg 


More information about the Qt-interest-old mailing list