I've been trying to figure-out this - documentation is pretty-much non-existant so I'll explain what I've found.
The QT Hack builds a tree out of the H1-H9 elements it finds and assigns them into (upto) 3 variables which are passed to header.html and footer.html
Section will be the last H1 element found (at the point the header/footer is inserted) - if there are no H1s, it will be the last H2 and so on
SubSection will be the next/lowest <H> element after the Section one
SubSubSection will be the... you get the idea
The code (outline.cc) which does this admits (in a comment) that there are possible problems doing this and it's easy to break it completely
I've seen issues where some elements are ignored for reasons I cannot fathom
It also doesn't reset headings when encountering higher headings (this is a straight-out bug really) - e.g.
H1
H2
H3
H2
At this point, you will still have the H3 element - even tho it's clearly not relevant
H1
At this point you still have the H2 AND H3 elements - now outright nonsense...
I've tried a few workarounds but I think the whole handling of Section/SubSection/SubSubsection needs redoing from-scratch - at the very least it must clear-out lower headings when it encounters new higher ones
Most people using these would be looking for some sort of 'breadcrumbs' display - e.g. H1 > H2 > H3 and you just cannot do that with the data it provides - at least not reliably...