[PyKDE] Multiple rows of column headers for QTable or QListView?

Quoc-Viet Dang qpdang at gotbackend.com
Wed Sep 22 18:55:22 BST 2004


Hi,
 I have recently started learning Qt/PyQt, so please bare with my
questions.
 I am attempting to make a QListView or QTable that has 2 rows of
column headers. The first row will be the parent headers, which may span
multiple columns. The second row will be the "sub headers" which are the
regular column headers that are found by default on the QTable and
QListViews. I am not sure whether I should implement this in QListView
or QTable or something completely different.

 I would like the top header to resize as the columns below it are
resized and vice versa. I am not sure which one would be easier to
implement (QTable or QListView). I am leaning toward QTable because I
also want to use row headers. Reorganizing columns with the spanning
headers will be considered later.

 Here is what I have planned:

Option 1:
Make a normal QTable or QListView. Draw another header directly above it
using QHeader. Have QHeader connected to the QTable via signals and
slots. Each time one is being resized, the other will follow.

Option 2:
Completely omit headers. Use the first 2 rows of cells as the headers,
which will eliminate the resizing issue. QTable supports spanning cells,
right? The issue with this option is the dragging of columns around.


ASCII Picture of what I want to accomplish
--------------------------------------
       |   Header  |      Header     |  <- Top Header
--------------------------------------
       | SH1 | SH2 | SH1 | SH2 | SH3 |  <- Sub Header
--------------------------------------
Header | Data| Dat | ... | ... | ... |  <- Cell Contents Start here
--------------------------------------


Sorting is an issue with both options, but this is a lesser issue and
will be dealt with once one of the options above is implemented.

Any pointers will be great.

Thank you very much,
Quoc-Viet




More information about the PyQt mailing list